reading stdout from a running win32 process

  • Thread starter Jules Stevenson
  • Start date
J

Jules Stevenson

Hi list,

I'm launching a process from windows using the demo 'winprocess' from the
win32 extensions. I want to be able to record the output of the process as
it runs and display it elsewhere. If I use the following [very bad] code:

import winprocess
import tempfile
import time

some_condition=True
out=tempfile.TemporaryFile()

#launch process
winprocess.run('xsibatch.exe', show=1, stdout=out, stderr=out)

while some_condition<20:
print out.read()
time.sleep(0.2)
some_condition+=1

out.close()

I don't seem to be able to read the 'out' at all? If I omit redirecting
stdout etc then the output displays fine in the console.

Any info / pointers on where I'm going very wrong much appreciated.

Jules
 
S

sturlamolden

I don't seem to be able to read the 'out' at all? If I omit redirecting
stdout etc then the output displays fine in the console.

You are redirecting to a file, not a pipe.

Read the file from beginning to end after your process had finished.
Or redirect to a pipe.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top