title: ssh paramiko cannot read output
body: <p>I am connecting to a server using <code>paramiko</code> and I'm trying to use <code>channel.send</code> to receive a sequential output. The script below fails to catch the output from <code>channel.recv</code>. Any ideas?</p>
  
  <pre><code>import paramiko
  ssh = paramiko.SSHClient()
  ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  ssh.connect("xx.xx.xx.xx",username='kshk',password='xxxxxxxx',key_filename='/home/krisdigitx/.ssh/id_rsa')
  channel = ssh.invoke_shell()
  channel.send('df -h\n')
  
  while channel.recv_ready():
      outp = channel.recv(1024)
  print outp
  </code></pre>
  
  <p>Gives:</p>
  
  <pre><code>krisdigitx@krisdigitx-Dell-System-XPS-L702X:~/SCRIPTS$ python test.py 
  Traceback (most recent call last):
    File "test.py", line 11, in &lt;module&gt;
      print outp
  NameError: name 'outp' is not defined
  </code></pre>
  
  <p>ruuning the script in interpreter mode works...</p>
  
  <pre><code>&gt;&gt;&gt; import paramiko
  &gt;&gt;&gt; ssh = paramiko.SSHClient()
  &gt;&gt;&gt; ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  &gt;&gt;&gt; ssh.connect("xx.xx.xx.xx",username='kshk',password='xxxxx',key_filename='/home/krisdigitx/.ssh/id_rsa')
  &gt;&gt;&gt; channel = ssh.invoke_shell()
  &gt;&gt;&gt; channel.send('df -h\n')
  6
  &gt;&gt;&gt; while  channel.recv_ready():
  ...     outp = channel.recv(1024)
  ... 
  &gt;&gt;&gt; print outp
  /dec/sda
                        7.2T  6.6T  622G  92% /tmp/xxx
  [kshk@server ~]$ 
  &gt;&gt;&gt; 
  </code></pre>