title: ssh with Subprocess.popen
body: <p>Hello All i'm stuck with a small problem. May be i'm missing something obvious but i'm unable to figure out the problem. I've GUI where i have a button named "erp" and if i press that it should do an <code>ssh</code> first to a machine named (host id name) <code>'ayaancritbowh91302xy'</code> and then it should execute commands like (cd change dir) and <code>'ls -l'</code>. I've tried the following code:</p>
  
  <pre><code>def erptool():
      sshProcess = subprocess.Popen(['ssh -T', 'ayaancritbowh91302xy'],stdin=subprocess.PIPE, stdout = subprocess.PIPE)
      sshProcess.stdin.write("cd /home/thvajra/transfer/08_sagarwa\n")
      sshProcess.stdin.write("ls -l\n")
      sshProcess.stdin.write("echo END\n")
      for line in stdout.readlines():
          if line == "END\n":
          break
          print(line)
  </code></pre>
  
  <p>i got the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "Cae_Selector.py", line 34, in erptool
      for line in stdout.readlines():
  NameError: global name 'stdout' is not defined
  Pseudo-terminal will not be allocated because stdin is not a terminal.
  </code></pre>
  
  <p>How to do this? can anyone help me with this?</p>