StrayanDropbear
StrayanDropbear

Reputation: 37

nohup: failed to run command

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.

Upvotes: 0

Views: 2620

Answers (1)

Yann Vernier
Yann Vernier

Reputation: 15887

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).

Upvotes: 1

Related Questions