Thanks to Artur! I solved my problem another way using his hint.How can i dump a password-protected database using perl (DBI or pg) or C (using libpq)? I can't pass the password to pg_dump utility (I was trying to pass it via tty also) when running system() from perl.
Isn't example below something like what you are trying to do:====8<==== #include <stdio.h> #include <stdlib.h> int main(void) { system("export PGDATABASE=\"test\"; export PGPASSWORD=\"test\"; export PGUSER=\"test\"; psql"); exit(0); } ====8<==== ? Here psql should connect to db 'test' as user 'test', password 'test'. Check if it works with pg_dump. I hope that helps! BTW - there are also other ways to do that... Check docs of your pg version. $PGPASSWORD is deprecated.
I needed to make backups of a non-constant set of DBs as a cron job. I connected to the main DB the usual way & made "select datname from pg_database". Then I setup the environment correctly & forked a child (pg_dump) for every DB in the list i got.
It will be a pity if $PGPASSWORD would dissapear in the future releases of PostgreSQL since users wouldn't be able to automate some DB maintainance tasks. I enjoy MySQL allowing to provide password @ the prompt actually. Maybe this feature would be added to Postgres later.
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
