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

2010-06-12 Thread Nobody
On Thu, 10 Jun 2010 08:40:03 -0700, Chris Seberino wrote: > On Jun 10, 6:52 am, Nobody wrote: >> Without the p1.stdout.close(), if the reader (grep) terminates before >> consuming all of its input, the writer (ls) won't terminate so long as >> Python retains the descriptor corresponding to p1.std

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

2010-06-11 Thread Steven W. Orr
On 6/10/2010 11:40 AM, Chris Seberino wrote: Even if zombies are created, they will eventually get dealt with my OS w/o any user intervention needed right? Bad approach. Years ago I inherited a server that didn't do a proper cleanup pf its slaves. After a few days running, people discovered t

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

2010-06-10 Thread Dan Stromberg
On Thu, Jun 10, 2010 at 4:52 AM, Nobody wrote: > > Also, "ls | grep" may provide a useful tutorial for the subprocess module, > but if you actually need to enumerate files, use e.g. os.listdir/os.walk() > and re.search/fnmatch, or glob. Spawning child processes to perform tasks > which can easily

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

2010-06-10 Thread Lie Ryan
On 06/10/10 21:52, Nobody wrote: > Spawning child processes to perform tasks > which can easily be performed in Python is inefficient Not necessarily so, recently I wrote a script which takes a blink of an eye when I pipe through cat/grep to prefilter the lines before doing further complex filteri

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

2010-06-10 Thread Chris Seberino
On Jun 10, 6:52 am, Nobody wrote: > Without the p1.stdout.close(), if the reader (grep) terminates before > consuming all of its input, the writer (ls) won't terminate so long as > Python retains the descriptor corresponding to p1.stdout. In this > situation, the p1.wait() will deadlock. > > The c

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

2010-06-10 Thread Grant Edwards
On 2010-06-10, Chris Seberino 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

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

2010-06-10 Thread Nobody
On Wed, 09 Jun 2010 21:15:48 -0700, Chris Seberino wrote: > How do subprocess.Popen("ls | grep foo", shell=True) with shell=False? The same way that the shell does it, e.g.: from subprocess import Popen, PIPE p1 = Popen("ls", stdout=PIPE) p2 = Popen(["gr

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

2010-06-09 Thread Chris Rebert
On Wed, Jun 9, 2010 at 9:15 PM, Chris Seberino 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"

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

2010-06-09 Thread Chris Seberino
How do subprocess.Popen("ls | grep foo", shell=True) with shell=False? Does complex commands with "|" in them mandate shell=True? cs -- http://mail.python.org/mailman/listinfo/python-list