amol kulkarni amol kulkarni - 4 years ago 87
Linux Question

Subprocess.Popen error

Proc = subprocess.Popen ([ 'FileName'])


The FileName is a variable which stores "/home/USER/exec.sh &", the program searches for the exec.sh file in the home folder and stores the path in FileName.I am unable to start this exec.sh process.It gives me the following error


OSError: [Errno 2] No such file or directory


I initially used::

os.system(FileName)


It worked perfectly but didn't return the pid. Thus, I switched to Popen.

Answer Source

just:

fileName = "/home/USER/exec.sh"
proc = subprocess.Popen(fileName)
pid = proc.pid
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download