How do subprocess.Popen("ls | grep foo", shell=True) with shell=False?

Chris Rebert clp2 at rebertia.com
Thu Jun 10 00:48:36 EDT 2010


On Wed, Jun 9, 2010 at 9:15 PM, Chris Seberino <cseberino at gmail.com> wrote:
> How do subprocess.Popen("ls | grep foo", shell=True) with shell=False?

I would think:

from subprocess import Popen, PIPE
ls = Popen("ls", stdout=PIPE)
grep = Popen(["grep", "foo"], stdin=ls.stdout)

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list