1

I am trying to telnet into a altusen power KVM and reboot a computer. when doing this using the windows telnet it works great. but when I use python's telnetlib, all read commands fail (not immediately but on timeout) again when using the windows telnet everything works fine, and I can see the login message

the following is the code I use: [on python 2.7.3]

import telnetlib
tn = telnetlib.Telnet("11.11.11.11")
print tn.read_all()//timeout fail,windows telnet does get a response

okay to clearify:

python No user input gets nothing read_all() times out normal windows telnet client No user input gets the following:



** ALTUSEN -- PN9108 Configuring Through Telnet **



Login:

Rincewind
  • 31
  • 6
  • 1
    Welcome to [so]. Please [edit] in the code that you are using along with the error you're getting. Adding more details will certainly get better attention and answers. – Bleeding Fingers Feb 05 '14 at 16:53
  • When you telnet to it with a regular telnet client, do you input anything? Does it just spit out data and then close the connection with no input? (The method you're using reads everything until it gets an EOF or a timeout; if the other end won't send an EOF it's not expected to ever return.) – Wooble Feb 05 '14 at 16:55
  • it spits a login message, and waits for a user input the above is not exactly my code, but it shows the basic failing point – Rincewind Feb 05 '14 at 17:05
  • If you won't share your exact code, you shouldn't expect us to provide an exact answer. For information about how to present a minimal, complete valid example, see http://stackoverflow.com/help/mcve or http://SSCCE.ORG/. For an approximate answer, consider using [`telnetlib.Telnet.expect()`](http://docs.python.org/2/library/telnetlib.html#telnetlib.Telnet.expect), as in this answer: http://stackoverflow.com/questions/19845525/accessing-a-telnet-session-in-python/19846878#19846878 – Robᵩ Feb 05 '14 at 19:51
  • I have used the python example, and it failed as well. I just didn't want people to focus on answers that explain that the read_until("login: ") won't catch anything, so I have put read_all() to show that not even a single byte is read using python, although telnet at the same stage gets a login screen – Rincewind Feb 06 '14 at 06:10

0 Answers0