I have one python content as below, and why I got ipmitool completion code is 00, but always return "failed"?
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")
1 Answer 1
The p.returncode is an int, so if it is successful it will be 0, which is False in your if statement, therefore it will execute print("failed")
answered Jun 8, 2017 at 13:56
Edwin van Mierlo
2,5181 gold badge12 silver badges20 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-py