Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Popen shell=False causes OSError: [Errno 2] No such file or directory

Tags:

python

popen

I am trying to run the below Popen command in OSX using shell=False:

command = "/usr/local/itms/share/iTMSTransporter.woa/iTMSTransporter -m verify -f /Volumes/Stuff/Temp/TMP_S_0_V_TV2.itmsp -u username -p password -o /Volumes/Stuff/Temp/TMP_S_0_V_TV2.itmsp/LOGFILE.txt -s provider -v eXtreme"
self.process1 = Popen(command, shell=False, stdin=PIPE)

But am getting this error:

    raise child_exception
OSError: [Errno 2] No such file or directory

What is going wrong? I also need this to function in Windows, I am aware of the directory paths, slashes, etc.

like image 975
speedyrazor Avatar asked May 21 '14 15:05

speedyrazor


1 Answers

Popen's first argument should be a list of args. Otherwise you're telling it to find an executable named strangely. You can use shlex.split() to split correctly

like Popen(shlex.split(command), shell=False, stdin=PIPE)

further reading: Popen docs

like image 56
Kirill Zaitsev Avatar answered Sep 21 '22 10:09

Kirill Zaitsev