473,495 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

Feb 1 '07 #1
2 1466
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

Feb 1 '07 #2
Bi*************@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
Feb 1 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
12118
by: Frank de Bot | last post by:
Hi, occasionaly I find in my apache logs that fastcgi had a broken pipe error with php running as fastcgi. the logs are like this: -- > (32)Broken pipe: > FastCGI: comm with server...
4
10495
by: Brian | last post by:
'Ello, I'm writing a perl script to spawn child processes to execute jobs. The jobs are system calls. I use open(SYSCALL, "cmd |), to make the system calls because I need the pipe so I can log...
1
7749
by: AckMike | last post by:
I am trying to write client and server programs that communicate with named pipes. There is one multithreaded server that handles all of the requests and multiple multithread clients that make...
7
3687
by: Greg | last post by:
I am trying to implement the UNIX pipe command using C but with the "->" operator. Everything works fine with 1 pipe, but when I try to use 2 or more, it hangs up when reading the pipe_in...
6
6186
by: placid | last post by:
Hi all, I have been looking into non-blocking read (readline) operations on PIPES on windows XP and there seems to be no way of doing this. Ive read that you could use a Thread to read from the...
14
19679
by: Rochester | last post by:
Hi, I just found out that the general open file mechanism doesn't work for named pipes (fifo). Say I wrote something like this and it simply hangs python: #!/usr/bin/python import os
11
21166
by: 7stud | last post by:
Hi, Can someone explain what a broken pipe is? The following produces a broken pipe error: ---------- import subprocess as sub p = sub.Popen(, stdin=sub.PIPE, stdout=sub.PIPE)
0
920
by: schickb | last post by:
I'm trying to pipe data that starts life in an array('B') object through several processes. The code below is a simplified example. The data makes it through, but the wait() always hangs. Is there...
1
1807
by: Jean-Paul Calderone | last post by:
On Mon, 12 May 2008 17:35:44 -0700 (PDT), schickb <schickb@gmail.comwrote: Alas, you haven't actually closed src's standard input. Though you did close src.stdin, you didn't close the copy of it...
3
8657
by: Jeremy Sanders | last post by:
Hi - I have some code which works under linux. It starts a remote python process using subprocess and communicates to it via a pipe created by os.pipe. As far as I understand, child processes...
0
6991
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7196
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6878
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7373
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5456
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
649
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.