[Tutor] using popen(n) to intercept stdout

Hugo González Monteverde hugonz-lists at h-lab.net
Thu Feb 16 06:07:14 CET 2006


Hi Tim,

You  are correctly using the filehandles you have, but the man command 
must be sending the response into STDERR instead of STDOUT. This makes 
sense, since it is an error message.

Take a look at popen4() and popen3() which both let you catch the 
standard error of a process. Also, in more recent versions of Python, 
take a look at the module named Subprocess.

Hope that helps,

Hugo

> 
> Question:
> How do I intercept the first response?
> I.E. How do I get "No manual entry for nothere"
> into a variable?
> 
> The object is to call another process on the same machine and capture
> the output of that process, assuming that the child process is writing
> to stdout.
> 
> thanks
> tim
> 


More information about the Tutor mailing list