Is subprocess.Popen completely broken?

Skip Montanaro skip at pobox.com
Thu Mar 27 11:25:01 EDT 2008


Jerry Hill <malaclypse2 <at> gmail.com> writes:

> It's looking for an executable named "ls /tmp"  Since it can't find
> one, it raises an exception.
> 
> If you just want to replace an os.system call, you need to pass
> shell=True to Popen, like this:
> proc = subprocess.Popen("ls /tmp", shell=True)
> 
> That will get the shell to split your string into the program to be
> called, and the argument(s) to the program.  Alternatively, you can do
> it yourself by passing a sequence to Popen:
> proc = subprocess.Popen(["ls", "/tmp"])

Oh crap.  Missing the comma... *sigh*  Sometimes adjacent string literals
can be silent killers.

Sorry for the noise.

Skip





More information about the Python-list mailing list