-1
import sys,os
import subprocess
import pdb

pdb.set_trace()
findCMD = 'find . -name "pcapdump0"'
print os.getcwd()
print findCMD
out = subprocess.Popen(findCMD,stdout=subprocess.PIPE)
(stdout, stderr) = out.communicate()
filelist = stdout.decode().split()
print filelist

I am getting this error

Traceback (most recent call last):
File "generatepcap.py", line 10, in <module>
out = subprocess.Popen(findCMD,stdout=subprocess.PIPE)
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Anthon
  • 69,918
  • 32
  • 186
  • 246
  • Be more specific! What do you want to achieve, which part of the code leads to the problem, .... Does the call of find return any files? – Stibu May 15 '15 at 06:03
  • 1
    Popen expects sequence of arguments, not single huge string. Use `subprocess.Popen(shlex.split(findCMD), stfout=subprocess.PIPE)`. – Łukasz Rogalski May 15 '15 at 06:40
  • Duplication of [that question](http://stackoverflow.com/questions/11566967/python-raise-child-exception-oserror-errno-2-no-such-file-or-directory). Refer to the link for further explainations. – Maoritzio May 15 '16 at 06:54

1 Answers1

2

Simply means what it says: popen can't find the command you specified, because you did not split the string.

Marcus Müller
  • 34,677
  • 4
  • 53
  • 94