title: Connect to server via ssh, check if chef is installed and record servers that it is not installed on
body: <p>I need to check a lot of servers if they have chef installed (Don't ask) I was trying to automate it instead of doing it manually. I have never used python before and I can't really test this until I go in tomorrow so was looking for some feed back if I am on the right track.I figure I dump all the IP address's into a text file, loop through it and save the ones that need to have chef installed.</p>
  
  <pre><code>import pxssh
  import getpass
  CheckIT = str("command not found")
  
  for line in open('ServerList.txt','r').readlines():
  
  try:                                                            
  s = pxssh.pxssh()
  hostname = raw_input('line ')
  username = raw_input('username ')
  password = getpass.getpass('password: ')
  s.login (hostname, username, password)
  s.sendline ('sudo su -')   # run a command
  s.prompt()             # match the prompt
  s.sendline ('chef-client')
  s.prompt()
  if CheckIT == readline(self,size=-1)
  with open("ServersToUpdate.txt", "a") as myfile:
  myfile.write(hostname)
  
  
  except pxssh.ExceptionPxssh, e:
  print "pxssh failed on login."
  print str(e)
  </code></pre>