Is subprocess.Popen completely broken?
skip at pobox.com
Thu Mar 27 16:25:01 CET 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.
More information about the Python-list