[python-win32] How to monitor the stdout/stderr of somecmd.exe
Ray Schumacher
rays at blue-cove.com
Fri Jun 25 12:17:35 EDT 2004
>-----Original Message-----
>From: python-win32-bounces+jim.vickroy=noaa.gov at python.org
>[mailto:python-win32-bounces+jim.vickroy=noaa.gov at python.org]On Behalf
>Of byo
>Sent: Saturday, June 19, 2004 6:36 PM
>To: python-win32 at python.org
>Subject: [python-win32] How to monitor the stdout/stderr of somecmd.exe
>
>
>I'd like to write a python program that will monitor the stdout/stderr
>of an executable (somecmd.exe) running on W2K. (simulated by sometask.py
>as below) I'm trying to react to it's output *as it is happening* (eg.
>thru monitor_sometask.py) by using win32pipe, but I find that I'm only
>getting the pipe's output too long after the fact. How can I monitor the
>output of somecmd.exe as it happens ? Thanks in advance.
This test interactively controls an old FORTRAN 85 program by using
pipedream.py
http://www.speakeasy.org/~bob_green/pipedream/:
import pipedream, time
pd = pipedream.PipeDream("frbpv5.exe")
pd.SendLine("")
pd.SendLine("1")
time.sleep(1)
while pd.HasDataWaiting():
print pd.ReadLine(1)
time.sleep(1)
pd.SendLine("2")
pd.ConsumeUpTo("", num = 1)
try:
while pd.HasDataWaiting():
print pd.ReadLine(timeout = 1)
except:
pass
pd.HasDataWaiting()
pd.SendLine("1")
pd.ReturnUpTo("SPEEDS -->", num = 1)
pd.ReceiveProtocol(" Continue")
pd.Shutd
Ray Schumacher
http://rjs.org
More information about the Python-win32
mailing list