psql Automatic login In Bash Script - Mailing list pgsql-admin

From Sai Hertz And Control Systems
Subject psql Automatic login In Bash Script
Date
Msg-id 40044B5D.9040909@sancharnet.in
Whole thread Raw
Responses Re: psql Automatic login In Bash Script  (Peter Eisentraut <peter.eisentraut@credativ.de>)
List 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

pgsql-admin by date:

Previous
From: Manuel Sugawara
Date:
Subject: Re: Error on system startup
Next
From: Sai Hertz And Control Systems
Date:
Subject: Re: psql Automatic login In Bash Script