Re: Pass password in scripts?

From: "Burak Seydioglu" <buraks78(at)gmail(dot)com>
To: "Neil Aggarwal" <neil(at)jammconsulting(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Pass password in scripts?
Date: 2007-02-15 01:28:30
Message-ID: 1b8a973c0702141728x6d398f58td34249d4254a8867@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I have two solutions that might help.

PHP:

system("echo -n -e \"".$password."\n\" | pg_dump -W --host=".$host."
-U ".$user." ".$database." > ".$backup_file,$output);

Try replacing pg_dump command with "psql -d database -U user"

BASH:

PGDATABASE=database
PGUSER=user
PGPASSWORD=password

export PGUSER PGPASSWORD

HTH,

Burak

On 2/14/07, Neil Aggarwal <neil(at)jammconsulting(dot)com> wrote:
> Hello:
>
> I have several scripts I would like to run against a database.
>
> With mysql, I can pass the password to the database in
> the command line call to the terminal client.
>
> Is there a way to do that with psql?
>
> There is no corresponding user account for
> the database user account.
>
> Thanks,
> Neil
>
>
> --
> Neil Aggarwal, (214)986-3533, www.JAMMConsulting.com
> FREE! Eliminate junk email and reclaim your inbox.
> Visit http://www.spammilter.com for details.
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match
>

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Jan Danielsson 2007-02-15 01:31:31 Re: Pass password in scripts?
Previous Message Neil Aggarwal 2007-02-15 00:15:31 Pass password in scripts?