newbie: how to capture/write to stdio on NT

Sholtz nospam at nospam.com
Sat May 22 14:13:35 EDT 2004


Hi,

I am trying to figure out how to 'control' the input & output using
popen/popen2 etc on Python 2.3
I have found examples for unix such as the one below but I can't get it to
work on Windows NT.

If I use the os.popen module I can read OR write not both.

Anybody have any ideas?

Regards,

Sholto.

# Open command in a pipe
# which reads from stdin and writes to stdout

import popen2
pipe = popen2.Popen4("wc -l") # Unix command
pipe.tochild.write("line 1\nline 2\nline 3\n")
pipe.tochild.close()
output = pipe.fromchild.read()





More information about the Python-list mailing list