Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Writing to open subprocess pipes.

Reply
Thread Tools

Writing to open subprocess pipes.

 
 
Brandon McGinty
Guest
Posts: n/a
 
      06-16-2010
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,
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
 
Reply With Quote
 
 
 
 
Nobody
Guest
Posts: n/a
 
      06-17-2010
On Wed, 16 Jun 2010 16:29:42 -0400, Brandon McGinty wrote:

> Both subprocess and os.popen* only allow inputput and output one time,
> and the output to be read only when the process terminates.


This is incorrect; you can read from and write to the pipe as you wish.
However: you may have problems if the child process buffers its output,
which is the default behaviour for stdout when it isn't associated with a
tty.

On Unix, you can get around this issue using the pty module. I don't know
about Windows; look into what "expect" uses.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to print stdout before writing stdin using subprocess module in Python? Sarbjit singh Python 2 07-23-2012 06:29 PM
how to import subprocess into my 'subprocess.py' file hiral Python 2 05-05-2010 12:56 PM
writing consecutive data to subprocess command 'more' SanPy Python 4 05-03-2009 07:06 AM
Help needed: file writing problem with subprocess Pekka Niiranen Python 4 12-05-2005 06:58 PM
[Subprocess/Windows] subprocess module under Windows 98 Andreas Jung Python 2 11-02-2005 05:41 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57