October 15th, 2002, 06:45 AM
Password prompt in script ??
I have the following statement...
which was working perfectly well using 'trust' authentication.
psql test -c "update d_conf_backup set name=to_char(now(), 'DDMONYYYYHH24MI')"
However, now I have changed the database setting to 'md5' for encrypted password authentication.
Now, the above code fails with...
I tried passing the password in the above code using -U & -W but it does not work. Is any other option is available ?
Do give your valuable input.
October 15th, 2002, 06:48 PM
I think for using md5, you will have to setup postgres password and/or shadow files. Note that these are not the UNIX password and shadow files, but are a postgres specific version of thems separate from UNIX. Section 4.2.2 explains it in more detail:
Did you also setup the user with encrypted password?
CREATE USER test WITH ENCRYPTED PASSWORD 'blah';
This user also referred to setting up md5 in the pg_hba.conf file:
Last edited by Ted Striker; October 15th, 2002 at 06:51 PM.
October 15th, 2002, 11:47 PM
Thanks for your reply. The info was very useful.
However, I'm sorry to have not been clear in my posting...
I'm able to connect using a password, ...
however when I want to connect using a script to take backup, it fails with the error mentioned as there is no password supplied.
So, for this, I wonder if there is an option to pass a password in the script.
October 16th, 2002, 02:31 AM
What error messages do you get when you use the -U & -W ?
October 16th, 2002, 03:17 AM
It still asks for password ...
October 16th, 2002, 01:28 PM
Looks like this is beyond me. Perhaps there is some kind of certificate or password file that needs to be set up.
Your best bet here would be to get on one of the Postgres mailing lists. Sometimes Tom Lane or Bruce Momjain will respond personally.
October 17th, 2002, 01:40 PM
You can pass a password in a script, it just isn't easy on 7.2 - I believe 7.3 will have a better fix for this by allowing you to specify a password file.
You can try env. vars PGUSER PGPASSWORD, although some os's will display that in ps - not a good idea for security.
Here's another method that will let the password be accepted from stdin.
October 19th, 2002, 03:58 AM
Thanks a mil ! This worked out.