Re: Providing the password to psql from a script - Mailing list pgsql-general

From Troy Campano
Subject Re: Providing the password to psql from a script
Date
Msg-id 1076977393.6880.6.camel@floweria.troygeek.net
Whole thread Raw
In response to Re: Providing the password to psql from a script  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-general
Try this...i'm using this with pg_dump


echo -n -e "username\npassword\n" | pg_dump -u -v dbname > dbname.pgdump



thanks!


On Sat, 2004-02-14 at 15:53, Martijn van Oosterhout wrote:
> On Sat, Feb 14, 2004 at 05:11:14PM +0100, Willem Herremans wrote:
> > I have used the Tcl command
> >
> >    set psqlChannel [open "|psql $dbname" RDWR]
> >
> > to create a channel that effectively becomes the input/output channel
> > for psql. By writing to that channel, SQL statements are sent to psql,
> > by reading from that channel, the results are received from psql.
> >
> > That works fine, as long as psql does not prompt for a password. The
> > problem is that psql does not use this channel for prompting for or
> > reading the password. Instead, the password is prompted for on, and read
> > from, the terminal from which the tcl application was started and that
> > is not what I want, because the Tcl application has already received the
> > password from the user. It is, as if psql does not use stdout and stdin
> > for the password.
>
> Look in the manpage for psql, there are several ways to stop it asking for
> passwords, including the PGPASS environment variable, tne .pgpass file and
> setting the user as trust in the config.
>
> Any of these will do what you want...
>
> Hope this helps,


pgsql-general by date:

Previous
From: Troy Campano
Date:
Subject: Re: [ADMIN] create ONE database beyond between 2 server
Next
From: Peter Eisentraut
Date:
Subject: Re: Fosdem