我有一个python内容如下,为什么我得到ipmitool完成代码是00,但总是返回"失败"?
import subprocess
def sdr(hostname,username,password):
IPMI_SERVER=hostname
IPMI_USERNAME=username
IPMI_PASSWORD=password
p = subprocess.run(["ipmitool.exe", "-H", IPMI_SERVER, "-U", IPMI_USERNAME, "-P", IPMI_PASSWORD, "-I", "lanplus", "raw", "0x06","0x01"], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
#p = subprocess.run(["ipmitool.exe -H 192.168.2.140 -I lanplus -U admin -P admin sdr elist full"], stdout=subprocess.PIPE)
output= p.returncode
return output
if sdr("192.168.2.140","admin","admin"):
print ("successfully")
else:
print ("failed")
答案 0 :(得分:1)
stream.js:74
throw er; // Unhandled stream error in penter code hereipe.
^
Error: spawn /media/sf_localdev/curriculo/node_modules/phantomjs-prebuilt/lib/phantom\bin\phantomjs.exe ENOENT
at exports._errnoException (util.js:870:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
at onErrorNT (internal/child_process.js:344:16)
at nextTickCallbackWith2Args (node.js:441:9)
at process._tickCallback (node.js:355:17)
是p.returncode
,因此如果成功则会int
,0
声明为False
,因此会if
执行print("failed")