title: how to know whether the command executed properly or not with pxssh
body: <p>I am trying to automate ssh. I want to execute a command inside ssh and want to know whether the command executed properly or not. I am using the <code>pxssh</code> module to achieve this. I am able to execute the command but not able to get the status using <code>$</code> ?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>#!/usr/bin/python
  
  import pxssh
  
  host='syslog.plivo.com'
  user='root'
  command = 'abc'
  
  def connect(hostname,username):
      try:
          s = pxssh.pxssh()
          s.login(hostname,username)
          return s
      except Exception, e:
          print " Error connection: "+str(e)
  
  def send_command(ssh_session,command):
      ssh_session.sendline(command)
      #ssh_session.sendline("$?")
      #ssh_session.prompt()
      #print ssh_session.before
  
  def main():
      session=connect(host,user)
      send_command(session,command)
  
  if __name__ == "__main__":
      main()
  </code></pre>