I am developing a client application for postgreSQL in Tcl/Tk (see
http://gborg.postgresql.org/project/pfm ).
It mainly uses PgTcl or pgintcl. I don't have any problems with those,
but I am also trying to call psql from my application for SQL statements
typed directly by the user.
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.
It would already be helpful if I knew how to make a shell script that
first reads the password and then provides that password to psql, such
that the user is not prompted for the password again.
I have already tried bash constructions like
PASSWORD='blabla'
psql $dbname <<EOF
$PASSWORD
EOF
But the result is still that psql prompts for the password on the
terminal from which the script is run.
Does anybody know how to solve this problem?
Thanks in advance,
--
Willem Herremans