postgres backup script and popen2

F

flupke

Hi,

i made a backup script to backup my postgres database.
Problem is that it prompts for a password. It thought i
could solve this by using popen2.
I tested popen2 with dir (i'm on windows 2000, python 2.4.3)
and it works.
However when i try popen2 and my pg_dump command, it prompts
for a password and I was under the impression that i was
going to be able to dynamically communicate with the process.

sin, sout = popen2(backup_command)
sin.readline() # the password prompt
sout.write("password")
sin.readlines()

How can i catch the password prompt and feed the password
from my code?

Thanks,
Benedict
 
G

Gabriel Genellina

So that it shows up in `ps' output to anyone on the system? :)

Any solution has pros and cons... having the password in the source
code is not so good anyway...
 
N

Nikita the Spider

"Gabriel Genellina said:
pexpect could work. But a better way would be to supply the password
on the command line. I don't know how postgres does that things, but I
hope there is some way to automate the backup process...

See the Postgres documentation for the .pgpass file.
 
F

flupke

flupke schreef:
<snip>

Thanks for all the info.
I'm sure i will get it right this time :)

Benedict
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top