问题描述
正在执行以下脚本...
Executing the following script...
[...]
...导致错误:
CalledProcessError:命令 '[ping', '-q', '-c2', '-W1', '10.81.3.80 ']' 返回非零退出状态 1
CalledProcessError: Command '[ping', '-q', '-c2', '-W1', '10.81.3.80 ']' returned non-zero exit status 1
在 check_output
中添加stderr = STDOUT"并没有产生任何有用的反馈.
Adding "stderr = STDOUT" in check_output
did not produce any useful feedback.
如何获取有关错误的更多信息以便解决问题?
How can I obtain more information regarding the error so that I can troubleshoot it?
推荐答案
subprocess.check_output 在非零退出代码和 ping 上引发 CalledProcessErrorcode> 如果出现错误(例如,未知域名、站点已关闭、站点因某种原因阻止 ICMP 或您的 Internet 连接已关闭),则返回非零退出代码.
subprocess.check_output raises CalledProcessError on non-zero exit code, and ping
returns non-zero exit code if something is wrong (e.g. unknown domain name, or site is down, or site has ICMP blocked for some reason, or your Internet connection is down).
如果您想检查输出和退出代码,请使用 subprocess.Popen:
If you want to examine both output and exit code, use subprocess.Popen:
例子:
这篇关于Python 'subprocess' CalledProcessError: Command '[...]' 返回非零退出状态 1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!
本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!