Chaining programs with pipe
Steve Holden
steve at holdenweb.com
Wed Aug 22 00:35:17 EDT 2007
Grant Edwards wrote:
> On 2007-08-21, avishay <avishorp at yahoo.com> wrote:
>
>> I'm trying to chain two programs with a pipe (the output of
>> one feeding the input of the other). I managed to capture the
>> output and feeding the input of each program independently
>> with popen, but how do I tie them together?
>
> On Unix, you do the same thing you would in C. Create a pipe
> using os.pipe(), then run one program with stdout connected to
> the "write" end of the pipe and the other program with stdin
> connected to the "read" end of the pipe.
>
> Or you can take a bit of a shortcut by letting the subprocess
> module create the pipe for you:
>
> http://docs.python.org/lib/node536.html
>
>> Is there a solution that works equally on all platforms?
>
> The doc page for subprocess doesn't say what platforms support
> it. I've had a lot of problems trying to use the subprocess
> module on windows. As is typical for Windows, there are all
> sorts of special cases that either don't work at all or don't
> work the way they should. You pays your money and you takes
> your chances.
>
Grant:
I will shortly have to write some training material on using subprocess
under Windows, so if you have any pointers to where your accumulated
knowledge can be gleaned I would be grateful for the time saving.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------
More information about the Python-list
mailing list