Access stdout from external program.
Jean-Michel Pichavant
jeanmichel at sequans.com
Fri Jul 30 12:28:30 EDT 2010
Paul Lemelle wrote:
> JM,
>
> Thanks for the response.
>
> I am trying to capture the stdout of a program from another program.
> Example, I want to launch the below program from a second python
> script then capture the first's program stdout to a file or variable.
>
> Is this possible?
>
> Thanks again,
> Paul
>
use the subprocess module.
import subprocess
proc = subprocess.Popen(['echo', 'Hello World'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE )
out, err = proc.communicate()
print out
>> Hello World
more details here
http://docs.python.org/library/subprocess.html
JM
More information about the Python-list
mailing list