Chaining programs with pipe

Karthik Gurusamy kar1107 at
Wed Aug 22 02:40:35 CEST 2007

On Aug 21, 3:09 pm, avishay <avish... at> wrote:
> Hello
> 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? Is there a solution that works equally on all
> platforms?

Not sure on non-unix platforms, but in unix like platforms it's best
to reuse shell's power.

>>> import commands
>>> commands.getoutput('ls | wc')
'      4       4      24'


> Thanks,
> Avishay

More information about the Python-list mailing list