how do I pipe two processes?

Discussion in 'Python' started by Bilgehan.Balban@gmail.com, Feb 1, 2007.

  1. Guest

    Hi, I want to pipe output of process A to B, and read output of B from
    python. On Unix if I do the following:

    child_out, child_in = popen2("program_a | program_b")

    line = child_out.readline()

    I get "IOError: bad file descriptor" from Python, and broken pipe
    error from program_b. How do I do this right?

    Thanks,
    Bahadir
    , Feb 1, 2007
    #1
    1. Advertising

  2. On Feb 1, 10:12 am, wrote:
    > Hi, I want to pipe output of process A to B, and read output of B from
    > python. On Unix if I do the following:
    >
    > child_out, child_in = popen2("program_a | program_b")
    >
    > line = child_out.readline()
    >
    > I get "IOError: bad file descriptor" from Python, and broken pipe
    > error from program_b. How do I do this right?
    >
    > Thanks,
    > Bahadir


    Use the subprocess module, see the examples here:
    http://docs.python.org/dev/lib/node539.html

    Michele Simionato
    Michele Simionato, Feb 1, 2007
    #2
    1. Advertising

  3. Peter Otten Guest

    wrote:

    > Hi, I want to pipe output of process A to B, and read output of B from
    > python. On Unix if I do the following:
    >
    > child_out, child_in = popen2("program_a | program_b")
    >
    > line = child_out.readline()
    >
    > I get "IOError: bad file descriptor" from Python, and broken pipe
    > error from program_b. How do I do this right?


    In through the out door? From the docs:

    .... Returns the file objects (child_stdin, child_stdout) ...

    Peter
    Peter Otten, Feb 1, 2007
    #3
    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. lee, wonsun
    Replies:
    1
    Views:
    477
    Jack Klein
    Nov 2, 2004
  2. Jeff Rodriguez
    Replies:
    23
    Views:
    1,083
    David Schwartz
    Dec 9, 2003
  3. Neal Becker
    Replies:
    0
    Views:
    278
    Neal Becker
    Dec 14, 2008
  4. Replies:
    1
    Views:
    213
    Ben Morrow
    Jun 2, 2004
  5. Lothar Braun

    Child processes don't get the close on pipe

    Lothar Braun, Jun 2, 2012, in forum: Perl Misc
    Replies:
    3
    Views:
    545
    Rainer Weikusat
    Jun 3, 2012
Loading...

Share This Page