Home > Archive > PostgreSQL Administration > August 2005 > connect to postgres from shell scripts









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author connect to postgres from shell scripts
Hemapriya

2005-08-22, 1:23 pm

Hi,

I would like to know how to connect to postgres from
shell scripts using a password protected user.

Is there a way to embed the password in psql login.
It keeps prompting for the passwords.

Any hint is appreciated.

Thanks
Priya



____________________
____________________
____________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Devrim GUNDUZ

2005-08-22, 1:23 pm

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

On Mon, 22 Aug 2005, Hemapriya wrote:

> I would like to know how to connect to postgres from
> shell scripts using a password protected user.
>
> Is there a way to embed the password in psql login.
> It keeps prompting for the passwords.


psql checks for PGUSER, PGPASSWORD, PGHOST, PGPORT, PGDATABASE and some
other environmental variables. Export relevant values to the parameters.

http://www.postgresql.org/docs/8.0/...bpq-envars.html

Also there's a .pgpass file thing:

http://www.postgresql.org/docs/8.0/...bpq-pgpass.html

Regards,
- --
Devrim GUNDUZ
Kivi Biližim Teknolojileri - http://www.kivi.com.tr
devrim~gunduz.org, devrim~PostgreSQL.org, devrim.gunduz~linux.org.tr
http://www.gunduz.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFDCgzAtl86P3SP
fQ4RAo5PAJ9y9Pm7ii8z
50ZrSB7Bws1qhQU++gCf
Uepu
C3ErI3WBVLPIJ8ShVPE2
9Dk=
=dCI+
-----END PGP SIGNATURE-----
---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Jason Minion

2005-08-22, 8:24 pm

Take a look at the .pgpass file, some info at:

http://www.postgresql.org/docs/8.0/...bpq-pgpass.html

Doing that, your password is still as secure as your .pgpass file,
which hopefully is more secure than your script.



-----Original Message-----
From: pgsql-admin-owner@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org]On Behalf Of Hemapriya
Sent: Monday, August 22, 2005 10:43 AM
To: pgsql-admin@postgresql.org
Subject: [ADMIN] connect to postgres from shell scripts


Hi,

I would like to know how to connect to postgres from
shell scripts using a password protected user.

Is there a way to embed the password in psql login.
It keeps prompting for the passwords.

Any hint is appreciated.

Thanks
Priya



____________________
____________________
____________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Tom Lane

2005-08-22, 8:24 pm

Devrim GUNDUZ <devrim@gunduz.org> writes:
> psql checks for PGUSER, PGPASSWORD, PGHOST, PGPORT, PGDATABASE and some
> other environmental variables. Export relevant values to the parameters.


PGPASSWORD is deprecated because it is insecure on some platforms
(to wit, those where other users can see a process' environment
variables via ps). The ~/.pgpass file is the recommended way to go.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Chris Travers

2005-08-26, 3:24 am

Hemapriya wrote:

>Hi,
>
>I would like to know how to connect to postgres from
>shell scripts using a password protected user.
>
>

psql is the simple way.

>Is there a way to embed the password in psql login.
>It keeps prompting for the passwords.
>
>
>

Use the .pgpass file to store the password.

Best Wishes,
Chris Travers
Metatron Technology Consulting

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com