postgres backup script and popen2
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: postgres backup script and popen2
Use pexpect: http://pexpect.sourceforge.net/ flupke schrieb: 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: postgres backup script and popen2
On 8 feb, 10:27, Maël Benjamin Mettler [EMAIL PROTECTED] wrote: flupke schrieb: 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. Use pexpect:http://pexpect.sourceforge.net/ 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... -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: postgres backup script and popen2
On 8 Feb 2007 08:23:49 -0800, Gabriel Genellina [EMAIL PROTECTED] wrote: On 8 feb, 10:27, Maël Benjamin Mettler [EMAIL PROTECTED] wrote: flupke schrieb: 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. Use pexpect:http://pexpect.sourceforge.net/ pexpect could work. But a better way would be to supply the password on the command line. So that it shows up in `ps' output to anyone on the system? :) Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: postgres backup script and popen2
On 8 feb, 13:29, Jean-Paul Calderone [EMAIL PROTECTED] wrote: On 8 Feb 2007 08:23:49 -0800, Gabriel Genellina [EMAIL PROTECTED] wrote: On 8 feb, 10:27, Maël Benjamin Mettler [EMAIL PROTECTED] wrote: flupke schrieb: 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. Use pexpect:http://pexpect.sourceforge.net/ pexpect could work. But a better way would be to supply the password on the command line. 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... -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: postgres backup script and popen2
On 8 Feb 2007 09:18:26 -0800, Gabriel Genellina [EMAIL PROTECTED] wrote: On 8 feb, 13:29, Jean-Paul Calderone [EMAIL PROTECTED] wrote: On 8 Feb 2007 08:23:49 -0800, Gabriel Genellina [EMAIL PROTECTED] wrote: On 8 feb, 10:27, Maël Benjamin Mettler [EMAIL PROTECTED] wrote: flupke schrieb: 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. Use pexpect:http://pexpect.sourceforge.net/ pexpect could work. But a better way would be to supply the password on the command line. So that it shows up in `ps' output to anyone on the system? :) Any solution has pros and cons... Some solutions have more or less of these than other solutions though. having the password in the source code is not so good anyway... Sure, but just because one has a password in the source doesn't mean one should completely give up. If you want to completely give up, you can just disable password authentication in pgsql. That's a lot simpler than any other solution mentioned so far. :) Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: postgres backup script and popen2
In article [EMAIL PROTECTED], Gabriel Genellina [EMAIL PROTECTED] wrote: On 8 feb, 10:27, Maël Benjamin Mettler [EMAIL PROTECTED] wrote: flupke schrieb: 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. Use pexpect:http://pexpect.sourceforge.net/ 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. -- Philip http://NikitaTheSpider.com/ Whole-site HTML validation, link checking and more -- http://mail.python.org/mailman/listinfo/python-list
Re: postgres backup script and popen2
flupke schreef: snip Thanks for all the info. I'm sure i will get it right this time :) Benedict -- http://mail.python.org/mailman/listinfo/python-list