how do I pipe two processes?

  • Thread starter Bilgehan.Balban
  • Start date
B

Bilgehan.Balban

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
 
M

Michele Simionato

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
 
P

Peter Otten

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top