Read/Write from/to a process

jas codecraig at
Mon Oct 24 16:20:42 CEST 2005

  I would like to start a new process and be able to read/write from/to
it.  I have tried things like...

import subprocess as sp
p = sp.Popen("cmd.exe", stdout=sp.PIPE)

however, it doesn't seem to work.  I think the cmd.exe is catching it.

I also tried
f = open("out.txt", "w")
sys.stdout = f

..but out.txt didn't contain any output from cmd.exe

So, how can I create a process (in this case, cmd.exe) on Windows and
be able to read/write from/to it?


More information about the Python-list mailing list