On Tue, 2007-10-30 at 12:05 +0100, Tronn Wærdahl wrote:
I have a shell script (sh) where I create a user and import data to a postgres database
<snip> su -c "createuser -A -D -P $PG_user" postgres su -c "psql -d$PG_database -h localhost -U$PG_user -W -f postgresql.sql " postgres </snip>
when the script executes those command, it ask for a password, how could I do this without have to enter the passwd, I would like that it reads the password from a variabel, that excists in a separate file, like
<variable file> PG_passwd=secret PG_user =username PG_database=simple </variable file>
---- not at all an answer to your question but what I have found to be useful is to use this in /var/lib/pgsql/data/pg_hba.conf
host all all 192.168.1.0/24 pam
which means that if the user exists and has his own database in postgres, the user authenticates against the normal auth system (pam) which is set to auth against LDAP which means that I don't have to worry about maintaining an extra password and if I disable the users login, it's disabled everywhere.
Craig