0

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

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.