0

For some strange reason when i run a python script with:

subprocess.Popen(["nohup", "openvpn --config '/usr/local/etc/openvpn/pia_openvpn/AU Melbourne.ovpn'"])

I get

nohup: failed to run command ‘openvpn --config '/usr/local/etc/openvpn/pia_openvpn/AU Melbourne.ovpn'’: No such file or directory

I can run openvpn --config "/usr/local/etc/openvpn/pia_openvpn/AU Melbourne.ovpn" with no errors. I've also tried running other commands and get the exact same error.

  • Possible duplicate of [Run a program from python, and have it continue to run after the script is killed](http://stackoverflow.com/questions/6011235/run-a-program-from-python-and-have-it-continue-to-run-after-the-script-is-kille) – Dekel Dec 03 '16 at 14:47

1 Answers1

1

You gave nohup one single argument containing spaces and quotes, and it failed to find a command with that name. Split it so the command is openvpn, with two more arguments (you'll probably find the extra quotes around the last argument shouldn't be there either). Sometimes this job is left to a shell, as with the system function, but that is in general riskier (similar to SQL injection) and inefficient (running another process for a trivial task).

Yann Vernier
  • 15,414
  • 2
  • 28
  • 26