[python-win32] How to monitor the stdout/stderr of somecmd.exe

Boris O byo at myrealbox.com
Fri Jun 25 01:46:26 EDT 2004


Hi Sean,

I tried it and it doesn't work for a variety of reasons :

win32pipe.popen takes only 2 arguments, it won't accept buffersize -
I tried os.popen but it insists that the buffersize parameter is set to 
-1 (very strange) Perhaps this is another question for another forum ...

Also,
f = win32pipe.popen("c:\python23\python sometask.py 2>1", 'r') simply 
redirects the output to a file called "1". I suspect that "2" is passed 
as a command line parameter. At any rate, it doesn't address how to read 
the output as it is happening.

I'm open to any other suggestions ...

Thanks

ps. apologies to the list for posting my question twice.

Sean wrote:
> ->f = win32pipe.popen("c:\python23\python sometask.py", 'r') while 1:
> 
> Redirect stderr (descriptor 2) to stdout (descriptor 1) and set the io
> buffer size to some number at least as small as your smalled expected
> output (could be 0 as well but I'm not 100% sure on how that will affect things).
> 
> buffersize=len("now: Fri Jun 18 10:22:43 2004    process : Fri Jun 18 10:22:36 2004")
> f = win32pipe.popen("c:\python23\python sometask.py 2>1", 'r', buffersize)
> 
> Hopefully that points you in the right direction.
> 
> That is all,
> 






More information about the Python-win32 mailing list