pipe related question

David Reed dreedmac at columbus.rr.com
Mon Nov 21 21:16:22 EST 2005


Is there any way to have one program run another arbitrary program  
with input from stdin and display the output as if you had run it in  
a shell (i.e., you'd see some of the output followed by the input  
they typed in and then a newline because they pressed return followed  
by subsequent output, etc.).

I can't use readline with the pipe because I don't know how much  
output the arbitrary program has before it calls an input statement.  
I've googled and understand that calling read() will deadlock when  
the program is waiting for input.

When I first write all the input to the input pipe and then call read  
on the output pipe it works just the same as if I had run the program  
as: program < input_file

What I'd like to see is the input intermixed with the output as if  
the user had typed it in.

Thanks,
Dave




More information about the Python-list mailing list