title: How to parse a Linux terminal error message in Python?
body: <p>I have written a small Python code to test it for a bigger project. The subprocess works great if everything's fine. But I want to parse the output error message for particular errors so I can figure out what the error is such as- IP not in network, or wrong username, wrong password.
  Even the print at the end doesnt work. My interest in however not to print those. I was merely checking if the parsing works!</p>
  
  <pre><code>import sys
  import subprocess
  import os 
  ip = "192.168.1.20"
  password = "password"
  username = "sam"
  ans = subprocess.check_output(['sudo','xfreerdp','-p',password, ip])
      for line in ans.split('\n'):
          if "protocol security negotiation" in line:
              print "Not Windows!"
  print "JUST TO test if this print works and it doesnt!!"
  </code></pre>