telnetlib problems

vercingetorix52 at yahoo.com vercingetorix52 at yahoo.com
Wed Mar 1 12:02:46 EST 2006


Thanks for the reply. I've replaced the call to read_very_eager() with
read_until() and enabled debugging messages.  My script now looks like
this...

#############################
import telnetlib

tn = telnetlib.Telnet('192.168.100.11')

tn.set_debuglevel(9)

tn.read_until('login: ', 5)

tn.write('user\n')

tn.read_until('Password: ', 5)

tn.write('password\n')

tn.read_until('bash-2.05$ ', 5)

tn.write('ls\n')

print tn.read_until('bash-2.05$ ', 5)
#############################

Each call to read_until() returns a valid string except for the second
one, i.e.,
tn.read_until('Password: ', 5) returns a null string.

Here's the program output with debugging enabled...
#############################
Telnet(192.168.100.11,23): recv "\xff\xfd\x18\xff\xfd
\xff\xfd#\xff\xfd'"
Telnet(192.168.100.11,23): IAC DO 24
Telnet(192.168.100.11,23): IAC DO 32
Telnet(192.168.100.11,23): IAC DO 35
Telnet(192.168.100.11,23): IAC DO 39
Telnet(192.168.100.11,23): recv
'\xff\xfb\x03\xff\xfd\x01\xff\xfd\x1f\xff\xfb\x05\xff\xfd!'
Telnet(192.168.100.11,23): IAC WILL 3
Telnet(192.168.100.11,23): IAC DO 1
Telnet(192.168.100.11,23): IAC DO 31
Telnet(192.168.100.11,23): IAC WILL 5
Telnet(192.168.100.11,23): IAC DO 33
Telnet(192.168.100.11,23): recv '\xff\xfb\x03'
Telnet(192.168.100.11,23): IAC WILL 3
Telnet(192.168.100.11,23): recv '\xff\xfb\x01Embedded Systems, 2050
Single Board Computer.\r\nR'
Telnet(192.168.100.11,23): IAC WILL 1
Telnet(192.168.100.11,23): recv 'uning \\s Kernel \\r.\r\nEmbedded:
2050 Special Feature'
Telnet(192.168.100.11,23): recv 's Enabled.\r\n\r\n'
Telnet(192.168.100.11,23): recv 'login: '
Telnet(192.168.100.11,23): send 'user\n'
Telnet(192.168.100.11,23): send 'password\n'
Telnet(192.168.100.11,23): recv 'Password: '
Telnet(192.168.100.11,23): send 'ls\n'
Telnet(192.168.100.11,23): recv '\r\n'
Telnet(192.168.100.11,23): recv 'Login incorrect\r\n\r\nlogin: '


Login incorrect



login:
#############################
It looks like it's sending the password before receiving the password
prompt.

Any ideas?




More information about the Python-list mailing list