I'm trying to find a specific string from a command output in terminal. It doesn't work however.
Here is the command I'm running:
check = subprocess.check_output("netctl list | sed -n 's/^\* //p'", shell=True)
That brings back one of two things. If you are not connected, it returns b'', otherwise it returns b'$networkname\n'.
The code I'm using to check it follows:
p = re.compile(r"\bb''\b")
if p.search("b''"):
print("False")
return False
else:
print("True")
return True
However, it returns true no matter what. I've also tried:
if check == "b''":
but that also returns true no matter what. I'm losing my mind here. What is causing it not to work?