Re: psql Automatic login In Bash Script

Lists: pgsql-admin
From: Peter Eisentraut <peter(dot)eisentraut(at)credativ(dot)de>
To: aspire420(at)hotpop(dot)com, Sai Hertz And Control Systems <sank89(at)sancharnet(dot)in>, pgsql-admin(at)postgresql(dot)org
Subject: Re: psql Automatic login In Bash Script
Date: 2004-01-13 19:47:28
Message-ID: 200401132047.28432.peter.eisentraut@credativ.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin

Sai Hertz And Control Systems wrote:
> What I need is since password be stored in the bash variable for
> once I may pass on the variable with password to
> psql
> pg_dump
> pg_restore
> and my database migration would go smothly

That would be a security hole because then other users can read the
password using 'ps'.

> Also would not like to set ~/.pgpass

Why not? That's what it's for.


From: Sai Hertz And Control Systems <sank89(at)sancharnet(dot)in>
To: pgsql-admin(at)postgresql(dot)org
Subject: psql Automatic login In Bash Script
Date: 2004-01-13 19:47:41
Message-ID: 40044B5D.9040909@sancharnet.in
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin

Dear all ,

I know this is a wrong list to for this post

Anyways

We use bash script for database maintainace and implimenting new
schema in the production database
the script goes as
<code>
#!/bin/sh
until [ "$uname" ]
do
read -s uname
done
until [ "$pass" ]
do
read -s pass
done
psql -U $uname mydatabase -f ./my_functions.sql
psql -U $uname mydatabase -f ./my_tables.sql
psql -U $uname mydatabase -f ./my_views.sql
</code>
The problem is psql has no option such that I can pass on the variable
$pass for password
and as you can see I have to type in password three times (in real
case 10 times)

What I need is since password be stored in the bash variable for once I
may pass on the variable with password to
psql
pg_dump
pg_restore
and my database migration would go smothly

Also would not like to set ~/.pgpass

Would be greateful to you all for any kinda help .

Regards,
Vishal Kashyap


From: Sai Hertz And Control Systems <sank89(at)sancharnet(dot)in>
To: Peter Eisentraut <peter(dot)eisentraut(at)credativ(dot)de>
Cc: aspire420(at)hotpop(dot)com, pgsql-admin(at)postgresql(dot)org
Subject: Re: psql Automatic login In Bash Script
Date: 2004-01-13 20:00:40
Message-ID: 40044E68.9020802@sancharnet.in
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin

Dear Peter Eisentraut

>>and my database migration would go smothly
>>
>>
>
>That would be a security hole because then other users can read the
>password using 'ps'.
>
>>Also would not like to set ~/.pgpass
>>Why not? That's what it's for.
>>
>>
Agreed and now we decided to use it but will ~/.pgpass work for
pg_dump
pg_restore

Regards,
Vishal Kashyap


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: aspire420(at)hotpop(dot)com, Sai Hertz And Control Systems <sank89(at)sancharnet(dot)in>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: psql Automatic login In Bash Script
Date: 2004-01-13 20:05:15
Message-ID: 200401132105.15238.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin

Sai Hertz And Control Systems wrote:
> Agreed and now we decided to use it but will ~/.pgpass work for
> pg_dump
> pg_restore

Yes, it works for all libpq programs.


From: Sai Hertz And Control Systems <sank89(at)sancharnet(dot)in>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: psql Automatic login In Bash Script
Date: 2004-01-13 20:32:28
Message-ID: 400455DC.6020609@sancharnet.in
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin

Dear Peter Eisentraut ,

Loads of thanks for you kind and much needed help.

Best Regards,
Vishal Kashyap

>>Agreed and now we decided to use it but will ~/.pgpass work for
>>pg_dump
>>pg_restore
>>
>>
>
>Yes, it works for all libpq programs.
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html
>
>
>
>