Ah. Thank you all for your quick responses. I shall implement
non-blocking stdin/stdout objects, then.
Thank You,
Brandon McGinty
On 6/16/2010 5:37 PM, Thomas Jollans wrote:
On 06/16/2010 10:29 PM, Brandon McGinty wrote:
All,
I have researched this both in the python documentation, and via google.
Neither subprocess nor os.popen* will do what I need.
First, I would instanshiate an ongoing shell, that would remain active
throughout the life of the socket connection.
I am trying to take commands, coming in from a standard python socket,
modify them, and then send them onto this shell, /bin/bash, for example.
The output of these modified commands will be received from the shell,
and sent back through the socket, possibly being modified further.
The connection on the other end of the socket will send multiple
commands, and will need output for each.
Both subprocess and os.popen* only allow inputput and output one time,
Is that a fact?
Does this not work:
from subprocess import Popen, PIPE
cat = Popen(["cat"], stdin=PIPE, stdout=PIPE)
cat.stdin.write("hello, world!\n")
cat.stdout.readline()
'hello, world!\n'
cat.stdin.write("and another line\n")
cat.stdout.readline()
'and another line\n'
and the output to be read only when the process terminates.
I need input and output to be read and written continuously, during the
lifetime of the shell.
I hope this makes sense, and if not, I shall do my best to elaborate
further.
I appreciate all the help this group has given me in the past, and I
certainly appreciate any help you all can offer now.
Sincerely,
Brandon McGinty
--
http://mail.python.org/mailman/listinfo/python-list