I have a program which tries to use the output of another script to decide what to do.
I take in the stdout of a Python process from an SSH session, the output of which is either "Verified" or "Unverified", which appears on the command line when I print it as ['Verified\n'].
My code is below. First I read in the output, then print it, then try to compare it. However it always comes out as the second option, that a does not equal verified – even when it should. Perhaps there is something I am missing about stdout, but I have tried many variations of the (if a == ) condition, including with the brackets I listed above. I’m not sure why it doesn’t work at all.
stdin, stdout, stderr = ssh.exec_command("python verify.py")
a = stdout.readlines()
print a
if (a == "Verified"):
print ("a does equal verified")
else:
print ("a does not equal verified")
readlines()returns a list and as you pointed out it returns with the\nHave you tried this?: