title: Telnet cisco switch using python
body: <p>I am telnetting to a cisco switch via python script. The code goes as follows:</p>
  
  <pre><code>#!/usr/bin/python
  import getpass
  import sys
  import telnetlib
  
  HOST = "10.203.4.1"
  user = raw_input("Enter your remote account: ")
  password = getpass.getpass()
  
  tn = telnetlib.Telnet(HOST)
  
  tn.read_until("login: ")
  tn.write(user + "\n")
  if password:
    tn.read_until("Password: ")
    tn.write(password + "\n")
  
  tn.write("vt100\n")
  tn.write("ls\n")
  tn.write("exit\n")
  print tn.read_all()
  </code></pre>
  
  <p>It just hangs up after running the script. How can I resolve this?</p>