Best way to capture output of another command-line program in Win32?

Fredrik Lundh fredrik at pythonware.com
Mon Feb 6 14:25:20 EST 2006


Peter A.Schott wrote:

> Not sure what I should do here.  I know that DOS/CMD can capture the output of
> EXE files in Win32.  I know that os.popen() has been recommended for this, but
> the couple of times I've tried, it didn't seem to work well.  I haven't had a
> lot of need to do this recently, but we're trying to automate some processes
> right now that require us to trap the output of a command line and react
> accordingly.
>
> Any suggestions on the best method for trapping this output?

import subprocess

(see the library reference for details.  if that doesn't work well, please post
a description of the problem, including tracebacks, test code, etc.)

</F> 






More information about the Python-list mailing list