subprocess.Popen output to file?

John Pye john.pye at gmail.com
Sat Apr 7 08:28:59 EDT 2007


Hi all

I am trying to set up a python script to manage backups of a mysql
database the 'right way' using pipes. I want to send the output of the
'mysqldump' command to a file. Using a normal shell script this would
be easy using a ">" operator. What is the efficient and best way to do
this using pure python, bearing in mind that it will be too much data
to keep in memory? I presume using the subprocess module, but how to
get the output to a file? It's not really documented, AFAICS.

Cheers
JP




More information about the Python-list mailing list