Clueless: piping between 2 non-python processes

Anthony Briggs abriggs at westnet.com.au
Sun Oct 26 01:25:34 EST 2003


At 5:00 PM +1100 26/10/03, Andrew Bennetts wrote:
>On Sun, Oct 26, 2003 at 05:08:44AM -0000, Donn Cave wrote:
>>  Quoth Andrew Bennetts <andrew-pythonlist at puzzling.org>:
>>  | On Sat, Oct 25, 2003 at 08:16:33PM +0200, Michael Lehmeier wrote:
>>  ...
>>  | > So the basic problem is:
>>  | > - create two processes A and B
>>  | > - pipe from A to B
>>  | > - terminate A when B ends
>>  |
>>  | I think you can do something like (untested):
>>
>>  Well, this is really more than he asked for.  All we need here is
>>  the same thing as the shell does with 'a | b', but instead of forking
>>  a from b as the shell would normally do it, both processes need to
>  > be children of the Python program so that it can wait for either.

The other, quick and dirty way to do it (depending on disk space, and 
whether it's time critical) is just to buffer it into a temporary 
file. So, execute two commands, os.system("A > tempfile") and 
os.system("cat tempfile | B"), and check to see whether either one of 
them returns 256.

Anthony
-- 
----------------------------------------------------
HyPEraCtiVE? HeY, WhO aRE YoU cALliNg HypERaCtIve?!
aBRiGgS at wEStNeT.cOm.aU
----------------------------------------------------





More information about the Python-list mailing list