Prev: using reverse in list of tuples
Next: grep command
From: Chris Seberino on 10 Jun 2010 00:15 How do subprocess.Popen("ls | grep foo", shell=True) with shell=False? Does complex commands with "|" in them mandate shell=True? cs
From: Chris Rebert on 10 Jun 2010 00:48 On Wed, Jun 9, 2010 at 9:15 PM, Chris Seberino <cseberino(a)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
From: Grant Edwards on 10 Jun 2010 10:04 On 2010-06-10, Chris Seberino <cseberino(a)gmail.com> wrote: > How do subprocess.Popen("ls | grep foo", shell=True) with shell=False? You'll have to build your own pipeline with multiple calls to subprocess > Does complex commands with "|" in them mandate shell=True? Yes. Hey, I've got a novel idea! Read the documentation for the subprocess module: http://docs.python.org/library/subprocess.html#replacing-shell-pipeline -- Grant Edwards grant.b.edwards Yow! ... My pants just went at on a wild rampage through a gmail.com Long Island Bowling Alley!!
|
Pages: 1 Prev: using reverse in list of tuples Next: grep command |