How do I automatically redirect stdout and stderr when using os.popen2?

Dennis Benzinger Dennis.Benzinger at gmx.net
Wed Jun 7 12:19:36 EDT 2006


mikem76 at gmail.com wrote:
> How do I automatically redirect stdout and stderr when using os.popen2
> to start a long running process.  If the process prints a lot of stuff
> to stdout it will eventually stop because it runs out of buffer space.
> Once I start reading the stdout file returned by os.popen2 then the
> process resumes.  I know that I could just specify > /dev/null when
> starting the process but I'd like to know if there is a way to start a
> process using os.popen2 or some other way so that all standard out and
> standard error goes to /dev/null or some other file.
> 
> Thanks,
> Mike
> 


Use the POpen class <http://docs.python.org/lib/node235.html> from the 
subprocess module.


Bye,
Dennis



More information about the Python-list mailing list