[英]nohup: failed to run command
For some strange reason when i run a python script with: 由于某些奇怪的原因,当我使用以下命令运行python脚本时:
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. 我可以正常运行
openvpn --config "/usr/local/etc/openvpn/pia_openvpn/AU Melbourne.ovpn"
。 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. 您给了
nohup
一个包含空格和引号的参数,但是它找不到具有该名称的命令。 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). 拆分它,使命令为
openvpn
,并带有另外两个参数(您可能会发现最后一个参数周围的多余引号也不应该存在)。 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). 有时,与
system
功能一样,这项工作留给外壳,但这通常风险更大(类似于SQL注入)并且效率低下(运行琐碎任务的另一个进程)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.