Re: passing passords to pgsql/pg_create/pg_dump programmatically

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: filippo <filippo2991(at)virgilio(dot)it>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: passing passords to pgsql/pg_create/pg_dump programmatically
Date: 2007-03-15 14:29:27
Message-ID: 20070315142927.GI5645@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

filippo wrote:
> Hello,
>
> I have written a program perl/Tkprogram, based on postgres. For
> maintenance reasons in my program I use these commands:
>
> `dropdb -U postgres -h $BACKUP_SERVER $BACKUP_DATABASE_NAME`;
> `createdb -U postgres -h $BACKUP_SERVER $BACKUP_DATABASE_NAME`;
> `pg_dump -U postgres -h $DATABASE_SERVER $DATABASE_NAME | psql -
> U postgres -h $BACKUP_SERVER $BACKUP_DATABASE_NAME`;
>
> my @psqlOutput = `psql -l -U postgres -h $_`;
>
>
> my program has a graphic interface but whenever I use these command,
> postgres ask for passord in the command line. How can I give these
> commands the right passowrd programmatically or how can I interact
> with these to give the passwords by a graphic box?

You can use the PGPASSWORD environment variable, or the ~/.pgpass file
(which can actually be somewhere else by using the PGPASSFILE
environment variable, allowing you to store passwords in /tmp or
something like that, to avoid destroying a .pgpass file the user may
have).

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

In response to

Browse pgsql-general by date

  From Date Subject
Next Message A. Kretschmer 2007-03-15 14:38:56 Re: PgSql on Vista?
Previous Message Alvaro Herrera 2007-03-15 14:27:17 Re: Could you send me a copy of pg8.1beta1?Thank you very much!