On Tue, Nov 13, 2012 at 9:25 AM, Ian Kelly <ian.g.ke...@gmail.com> wrote: > Sorry, the example I gave above is wrong. If you're calling > p1.communicate(), then you need to first remove the p1.stdout pipe > from the Popen object. Otherwise, the communicate() call will try to > read data from it and may "steal" input from p2. It should look more > like this: > >>>> p1 = subprocess.Popen(cmd1, shell=True, stdout=subprocess.PIPE, >>>> stderr=subprocess.PIPE) >>>> p2 = subprocess.Popen(cmd2, shell=True, stdin=p1.stdout, >>>> stdout=subprocess.PIPE, stderr=subprocess.PIPE) >>>> p1.stdout = None
Per the docs, that third line should be "p1.stdout.close()". :-P -- http://mail.python.org/mailman/listinfo/python-list