Accessing shell output from HTTP
brendon.wickham at gmail.com
Mon Mar 30 14:19:25 CEST 2009
I would like users of my web application to be able to download a backup
file of a database (using* *MySQL's *mysqldump* command).
My strategy is to use *zipfile* to create a zip file object (with the *
mysqldump* output as the contents of the zipped file) and then use *
sys.stdout* to send the zip file object to the user as a file for them
The zipping bit and file delivery is all sorted. Getting the output from *
mysqldump* is my problem and I'm not even sure (given that, as I understand
it, it's an asynchronous call to shell via an HTTP thread) it is even
This is as far as I've got:
import subprocess as sp
p1 = sp.Popen('mysqldump --opt
If I type the above into a Python prompt and print *backupfile* I will get
the expected result, but when I'm going through CGI (the script, called from
a web browser, is supposed to capture the output into the variable) nothing
is being returned by communicate().
Is this possible? Or am I barking up the wrong tree?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list