简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM