Skip site navigation (1) Skip section navigation (2)

Re: Creating users from shell or perl script

From: Mo Holkar <pgsql(at)digitalmindgames(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Creating users from shell or perl script
Date: 2001-11-23 09:39:23
Message-ID: 5.1.0.14.2.20011123093113.048cf680@pop.ntlworld.com (view raw or flat)
Thread:
Lists: pgsql-novice
At 06:59 23/11/01, you wrote:
>On Fri, 2001-11-23 at 03:29, Danny Aldham wrote:
> >=20
> > I have written a program that will install some software,
> > create a database, and create a couple of postgres users. Most
> > everything is working, but I cannot see how to create postgres
> > users with set passwords. If the script calls createuser the=20
> > prompts do not come to the user, and anyway I do not want them to.
> > I want to be able to create the user with a password and not have
> > the person running the script see it. Right now I am trying in perl:
> > $output =3D `/usr/local/pgsql/bin/createuser $New_User ` ;
>
>You don't have to do this through the shell scripts; you can use SQL
>directly:
>
>CREATE USER username WITH PASSWORD 'password'


If your situation is that you _have_to_ run it from the shell, you can run 
this single query with something like:

$ psql -c "CREATE USER username WITH PASSWORD 'password'"

or if you have a load of them to add and don't want to run a separate psql 
each time, you can read a set of queries in from a file using psql --file 
filename'

See the section of the docs on command-line options for psql, there's loads 
of useful things you can do with it.

best,

Mo



Mo Holkar
Digital Mind Games -- log on to take over
mo(dot)holkar(at)digitalmindgames(dot)com
http://www.digitalmindgames.com


In response to

pgsql-novice by date

Next:From: Mark G. FranzDate: 2001-11-23 15:12:56
Subject: Re: Update from a table.
Previous:From: Oliver ElphickDate: 2001-11-23 06:59:16
Subject: Re: Creating users from shell or perl script

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group