Read from stdouton Popen on WinXP?

fraca7 fraca7 at free.fr
Wed Aug 17 05:31:49 EDT 2005


mhenry1384 a écrit :
> I am trying to run a program and filter the output on Windows XP.
> Since I want to filter the output, I'd like to read it a line at a time
> and only print the lines I care about.

> [snip]

I had the exact same problem yesterday. This is an obvious use case for 
the "bufsize" parameter to os.popen4, except that the Windows 
implementation doesn't accept anything but -1...

The only way I can see out of this is to use win32api to launch the 
process through CreateProcess, then perform asynchronous I/O on its 
stdout using the OVERLAPPED structure in a call to ReadFile... Ugly...



More information about the Python-list mailing list