title: telnet connection is timed out via telnetlib while working via cmd
body: <p>I'm trying to use <a href="https://docs.python.org/2/library/telnetlib.html" rel="nofollow noreferrer">Telnet</a> to connect to my remote device. When using telnet via <em>cmd</em> I got no issues, and the prompt looks like this</p>
  
  <p><a href="https://i.stack.imgur.com/yBCJm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yBCJm.png" alt="enter image description here"></a></p>
  
  <p>As you can see, it requires:</p>
  
  <ol>
  <li><em>"user>"</em> (answer "su") and then</li>
  <li><em>"password>"</em> (answer "1234") and then the prompt is</li>
  <li><em>"mp4100#"</em></li>
  </ol>
  
  <p>Upon writing "?" (even without enter) the prompt spits out a huge string.
  I'm trying to mimic this, but nothing seems to be working...</p>
  
  <pre><code>import telnetlib
  
  HOST = "172.17.174.241"
  user = 'su'
  password = '1234'
  time_out = 2
  name = "mp4100"
  prompt = name + '#'
  
  tn = telnetlib.Telnet(HOST, timeout = time_out)
  tn.set_debuglevel(100)
  
  tn.read_until("user&gt;", time_out)
  tn.write(user + "\n")
  
  if password:
      tn.read_until("password&gt;", time_out)
      tn.write(password + "\n")
  
  #tn.read_until(prompt, time_out)
  tn.write('?')
  
  print tn.read_all() # shouldn't this write the string that the prompt wrote?
  tn.close()
  </code></pre>
  
  <p>When I run this it just freezes. </p>
  
  <hr>
  
  <p><strong>Edit</strong>: I added timeout to the connection, and that is where it freezes. The device won't connect via the script, even though through <em>cmd</em> it has no problems</p>
  
  <hr>
  
  <p>Code edited a bit to show what I'm doing right now. Output after adding <code>tn.set_debuglevel(100)</code> (What are the legal values for this function? didn't see it in the doc / spyder help)</p>
  
  <pre><code>Telnet(172.17.174.241,23): recv '\xff\xfb\x01'
  Telnet(172.17.174.241,23): IAC WILL 1
  Telnet(172.17.174.241,23): recv '\xff\xfb\x03'
  Telnet(172.17.174.241,23): IAC WILL 3
  Telnet(172.17.174.241,23): recv '\xff\xfc\x01'
  Telnet(172.17.174.241,23): IAC WONT 1
  Telnet(172.17.174.241,23): recv '\xff\xfc\x03'
  Telnet(172.17.174.241,23): IAC WONT 3
  Telnet(172.17.174.241,23): recv '\n\r'
  Telnet(172.17.174.241,23): recv '\n\ruser&gt;'
  Traceback (most recent call last):
  </code></pre>