Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   how do I pipe two processes? (http://www.velocityreviews.com/forums/t398786-how-do-i-pipe-two-processes.html)

Bilgehan.Balban@gmail.com 02-01-2007 09:12 AM

how do I pipe two processes?
 
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


Michele Simionato 02-01-2007 11:15 AM

Re: how do I pipe two processes?
 
On Feb 1, 10:12 am, Bilgehan.Bal...@gmail.com 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


Peter Otten 02-01-2007 12:54 PM

Re: how do I pipe two processes?
 
Bilgehan.Balban@gmail.com 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


All times are GMT. The time now is 12:30 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.