Writing to open subprocess pipes.

Discussion in 'Python' started by Brandon McGinty, Jun 16, 2010.

  1. 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
    Brandon McGinty, Jun 16, 2010
    #1
    1. Advertising

  2. Brandon McGinty

    Nobody Guest

    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.
    Nobody, Jun 17, 2010
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tom Plunket
    Replies:
    3
    Views:
    733
    Donn Cave
    Jan 9, 2007
  2. sven _
    Replies:
    1
    Views:
    494
    Mark Wooding
    Apr 22, 2008
  3. hiral
    Replies:
    2
    Views:
    573
    Jean-Michel Pichavant
    May 5, 2010
  4. Sébastien Cottalorda

    Pipes and non blocking writing

    Sébastien Cottalorda, Apr 20, 2004, in forum: Perl Misc
    Replies:
    2
    Views:
    190
    Sébastien Cottalorda
    Apr 20, 2004
  5. nuffi
    Replies:
    0
    Views:
    174
    nuffi
    Jul 13, 2012
Loading...

Share This Page