2009/7/3 hyou <[email protected]>:
> Hi Sander,
>
> Thanks for the reply. However, the reason that I have to use subprocess.call 
> is that if I use
> subprocess.Popen, the pipe sign "|" will break the execution of the command 
> (though I don't know
> why). Do you know how can I put "|" correctly in Popen then? (The same 
> command works fine both in
> Command prompt and subprocess.call, but not .Popen)

You create a Popen object for each program and redirect the stdout
from program 1 to subprocess.PIPE. Now in program 2 you read the
stdout from command 1 to the stdin. See below a simple example.

p1 = subprocess.Popen('command1', stdout = subprocess.PIPE)
p2 = subprovess.Popen('command2', stdin = p1.stdout)

Greets
Sander

PS: Please make sure you also reply to the list.
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to