title: how to get console output from a remote computer (ssh + python)
body: <p>I have googled "python ssh". There is a wonderful module <a href="http://www.noah.org/wiki/Pexpect" rel="noreferrer"><code>pexpect</code></a>, which can access a remote computer using ssh (with password). </p>
  
  <p>After the remote computer is connected, I can execute other commands. However I cannot get the result in python again. </p>
  
  <pre><code>p = pexpect.spawn("ssh user@remote_computer")
  print "connecting..."
  p.waitnoecho()
  p.sendline(my_password)
  print "connected"
  p.sendline("ps -ef")
  p.expect(pexpect.EOF) # this will take very long time
  print p.before
  </code></pre>
  
  <p>How to get the result of <code>ps -ef</code> in my case?</p>