The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Databases
> PostgreSQL Help
|
Password prompt in script ??
Discuss Password prompt in script ?? in the PostgreSQL Help forum on Dev Shed. Password prompt in script ?? PostgreSQL Help forum discussing administration, SQL syntax, or other PostgreSQL-related topics. PostgreSQL provides enterprise level database functionality at open source prices.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

October 15th, 2002, 06:45 AM
|
|
Contributing User
|
|
Join Date: Aug 2002
Location: Chennai, India
Posts: 69
Time spent in forums: 7 m 55 sec
Reputation Power: 11
|
|
|
Password prompt in script ??
I have the following statement...
Code:
psql test -c "update d_conf_backup set name=to_char(now(), 'DDMONYYYYHH24MI')"
which was working perfectly well using 'trust' authentication.
However, now I have changed the database setting to 'md5' for encrypted password authentication.
Now, the above code fails with...
Quote:
Password:
psql: fe_sendauth: no password supplied
|
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.
Thanks.
|

October 15th, 2002, 06:48 PM
|
|
Contributing User
|
|
Join Date: Jan 2002
Posts: 409
Time spent in forums: < 1 sec
Reputation Power: 12
|
|
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:
http://www.postgresql.org/idocs/ind...th-methods.html
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:
http://dbforums.com/t322752.html
Last edited by Ted Striker : October 15th, 2002 at 06:51 PM.
|

October 15th, 2002, 11:47 PM
|
|
Contributing User
|
|
Join Date: Aug 2002
Location: Chennai, India
Posts: 69
Time spent in forums: 7 m 55 sec
Reputation Power: 11
|
|
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, ...
Quote:
postgres@sun051 pgsql]$ psql run
Password:
Welcome to psql, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit
run=#
|
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.
Best Regards.
|

October 16th, 2002, 02:31 AM
|
|
Contributing User
|
|
Join Date: Jan 2002
Posts: 409
Time spent in forums: < 1 sec
Reputation Power: 12
|
|
|
What error messages do you get when you use the -U & -W ?
|

October 16th, 2002, 03:17 AM
|
|
Contributing User
|
|
Join Date: Aug 2002
Location: Chennai, India
Posts: 69
Time spent in forums: 7 m 55 sec
Reputation Power: 11
|
|
Quote: Originally posted by Ted Striker
What error messages do you get when you use the -U & -W ? |
It still asks for password ...
Quote:
[postgres@sun051 pgsql]$ cat bk3.sh
psql dev -U postgres -W postgres -c "update d_conf_backup set name=to_char(now(), 'DDMONYYYYHH24MI')"
psql dev -U postgres -W postgres -t -c "select 'pg_dump dev > dev'||name||'.dmp' from d_conf_backup" > bk4.sh
chmod 755 bk4.sh
[postgres@sun051 pgsql]$ ./bk3.sh
psql: warning: extra option postgres ignored
Password:
|
|

October 16th, 2002, 01:28 PM
|
|
Contributing User
|
|
Join Date: Jan 2002
Posts: 409
Time spent in forums: < 1 sec
Reputation Power: 12
|
|
|
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
|
 |
Contributing User
|
|
Join Date: May 2002
Posts: 56
Time spent in forums: < 1 sec
Reputation Power: 12
|
|
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.
http://groups.google.com/groups?q=p...guin.com&rnum=3
__________________
Casuistry Agnostic
|

October 19th, 2002, 03:58 AM
|
|
Contributing User
|
|
Join Date: Aug 2002
Location: Chennai, India
Posts: 69
Time spent in forums: 7 m 55 sec
Reputation Power: 11
|
|
Thanks a mil ! This worked out.
Regards.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|