Discussion:
Connect to postgres from a script using password
(too old to reply)
Hemapriya
2004-07-08 16:07:30 UTC
Permalink
Hi,

Can anyone tell me how to connect to postgres from a
shell script using password. If i use psql -UUser db
-W option it prompts for password everytime..
Is there anyway we can have the password included in
psql login command.?

Thanks
Priya



__________________________________
Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.
http://promotions.yahoo.com/new_mail

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
Devrim GUNDUZ
2004-07-08 16:44:09 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hi,
Post by Hemapriya
Can anyone tell me how to connect to postgres from a
shell script using password. If i use psql -UUser db
-W option it prompts for password everytime..
Is there anyway we can have the password included in
psql login command.?
Try environmental variables. I use this one:

==========================
export PGPASSWORD=password
export PGUSER=username
psql dbname
==========================

Using ~/.pgpass might be another alternative.

Regards,
- --
Devrim GUNDUZ
devrim~gunduz.org devrim.gunduz~linux.org.tr
http://www.tdmsoft.com
http://www.gunduz.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFA7Xnbtl86P3SPfQ4RAjNZAKDpOVd0wpOu0y3IDYPbq5tG9RFEgACeKDmC
Pgbg6AI0xK3vWh2fW3SCZ8Q=
=1Qfo
-----END PGP SIGNATURE-----


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
Bruno Wolff III
2004-07-08 16:47:36 UTC
Permalink
On Thu, Jul 08, 2004 at 09:07:30 -0700,
Post by Hemapriya
Hi,
Can anyone tell me how to connect to postgres from a
shell script using password. If i use psql -UUser db
-W option it prompts for password everytime..
Is there anyway we can have the password included in
psql login command.?
You can keep the password in ~/.pgpass or you can use ident authentication.
In at least some versions you can pass it through an environment variable,
but you don't want to do that if there are untrusted users with shell
access to the host, as environment variables are typically visible to other
users.

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Loading...