Thread: supplying password to psql on command line?

supplying password to psql on command line?

From
Stan Letovsky
Date:
Is this possible? The documentation is silent in this point. SYBASE
isql allows this by flag or environment variable.

Cheers, -Stan


Re: supplying password to psql on command line?

From
Andrew Sullivan
Date:
On Thu, Oct 24, 2002 at 10:59:10AM -0400, Stan Letovsky wrote:
> Is this possible? The documentation is silent in this point. SYBASE
> isql allows this by flag or environment variable.

Try the environment variable PGPASSWORD.

A

--
----
Andrew Sullivan                         204-4141 Yonge Street
Liberty RMS                           Toronto, Ontario Canada
<andrew@libertyrms.info>                              M2P 2A8
                                         +1 416 646 3304 x110


Re: supplying password to psql on command line?

From
Christoph Dalitz
Date:
> Date: Thu, 24 Oct 2002 10:59:10 -0400 (EDT)
> From: Stan Letovsky <stan@morgan.harvard.edu>
>
> Is this possible? The documentation is silent in this point. SYBASE
> isql allows this by flag or environment variable.
>
Use the environment variable PGPASSWORD.

Christoph Dalitz

Re: supplying password to psql on command line?

From
Medi Montaseri
Date:
I think Font ends are moving away from this approach as others can see
your supplied
passwd by a simple ps(1) command.

Stan Letovsky wrote:

>Is this possible? The documentation is silent in this point. SYBASE
>isql allows this by flag or environment variable.
>
>Cheers, -Stan
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 4: Don't 'kill -9' the postmaster
>
>




Re: supplying password to psql on command line?

From
Christoph Dalitz
Date:
> Date: Mon, 28 Oct 2002 10:56:32 -0800
> From: Medi Montaseri <medi.montaseri@intransa.com>
>
> I think Font ends are moving away from this approach as others can see
> your supplied
> passwd by a simple ps(1) command.
>
There used to be a program "hide.c" available from the oracle website,
which made this impossible. Unfortunately I can no longer find it.

A simpler approach however is to supply the password from stdin.
With Oracle's sqlplus this works as follows:

    #!/bin/sh

    sqlplus <<EOF
    userid/password@tnasalias
    /* SQL commands */
    EOF

Unfortunately this does *not* work with psql because for some strange reason
psql does not read the password from stdin.

Christoph Dalitz

Re: supplying password to psql on command line?

From
Christoph Dalitz
Date:
> > I think Font ends are moving away from this approach as others can see
> > your supplied
> > passwd by a simple ps(1) command.
> >
> There used to be a program "hide.c" available from the oracle website,
> which made this impossible. Unfortunately I can no longer find it.
>
Found it here:
ftp://ftp.usg.edu/pub/oracle/security/hideargs/

Christoph Dalitz

Re: supplying password to psql on command line?

From
Alvaro Herrera
Date:
On Tue, Oct 29, 2002 at 08:52:12AM +0100, Christoph Dalitz wrote:
>
> > Date: Mon, 28 Oct 2002 10:56:32 -0800
> > From: Medi Montaseri <medi.montaseri@intransa.com>
> >
> > I think Font ends are moving away from this approach as others can see
> > your supplied
> > passwd by a simple ps(1) command.

> Unfortunately this does *not* work with psql because for some strange reason
> psql does not read the password from stdin.

You can always use PGPASSWORD.  And for those of you that find that
envvar insecure or cumbersome, there's a new ~/.pgpass where you can
store passwords in 7.3.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
Y dijo Dios: "Que sea Satanás, para que la gente no me culpe de todo a mí."
"Y que hayan abogados, para que la gente no culpe de todo a Satanás"

Re: supplying password to psql on command line?

From
Bruce Momjian
Date:
Christoph Dalitz wrote:
>
> > Date: Mon, 28 Oct 2002 10:56:32 -0800
> > From: Medi Montaseri <medi.montaseri@intransa.com>
> >
> > I think Font ends are moving away from this approach as others can see
> > your supplied
> > passwd by a simple ps(1) command.
> >
> There used to be a program "hide.c" available from the oracle website,
> which made this impossible. Unfortunately I can no longer find it.
>
> A simpler approach however is to supply the password from stdin.
> With Oracle's sqlplus this works as follows:
>
>     #!/bin/sh
>
>     sqlplus <<EOF
>     userid/password@tnasalias
>     /* SQL commands */
>     EOF
>
> Unfortunately this does *not* work with psql because for some strange reason
> psql does not read the password from stdin.

psql will read the password from stdin if there is no controlling
terminal on /dev/tty.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073