Please read the documentation of Popen. You cannot pass arguments like that.
>>> from subprocess import Popen,PIPE >>> import shlex >>> cmd="ls -l" >>> cmd=shlex.split(cmd) >>> p = Popen(cmd,stdout=PIPE,stderr=PIPE) or simply that means >>> p = Popen(['ls','-l'],stdout=PIPE,stderr=PIPE) Hope I have made my point clear. The problem occuring is that there is no binary that has name as "ls -l". Python cannot understand that "-l" is an argument until you pass it this way. On Tue, Oct 26, 2010 at 6:52 PM, Sean Carolan <scaro...@gmail.com> wrote: > What am I doing wrong here? > > >>> from subprocess import Popen, PIPE > >>> cmd = 'ls -l' > >>> p = Popen(cmd, stdout=PIPE, stderr=PIPE) > Traceback (most recent call last): > File "<stdin>", line 1, in ? > File "/usr/lib64/python2.4/subprocess.py", line 550, in __init__ > errread, errwrite) > File "/usr/lib64/python2.4/subprocess.py", line 993, in _execute_child > raise child_exception > OSError: [Errno 2] No such file or directory > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > -- Abhijeet Rastogi (shadyabhi) http://www.google.com/profiles/abhijeet.1989
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor