Read/Write from/to a process
Michael Schneider
michaelschneider at fuse.net
Tue Oct 25 10:38:43 EDT 2005
Jas,
I use a python called twisted to run processes as you describe.
Twisted is an event-driven framework that brings a change in the
way that you look at things.
take a look at:
http://twistedmatrix.com/projects/core/documentation/howto/process.html
Good luck, hope this is useful,
Mike
jas wrote:
> Hi,
> 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)
> p.stdin.write("hostname\n")
>
> 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
> os.system("cmd.exe")
>
> ..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?
>
> Thanks
>
--
The greatest performance improvement occurs on the transition of from
the non-working state to the working state.
More information about the Python-list
mailing list