On 21 ago, 21:40, Karthik Gurusamy <[EMAIL PROTECTED]> wrote: > On Aug 21, 3:09 pm, avishay <[EMAIL PROTECTED]> 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? 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')
Using the shell is OK but I think the subprocess module is more portable. This example is on Windows: import subprocess subprocess.call("dir /b | sort", shell=True) ~DFDADD.tmp ~DFF71E.tmp 1.bak 1.cmd 1.csv 1.py 1.txt 2.py 2A0B17.dmp [...] -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list