Telnetlib & Term Types

S

Svha

Greetings

I'd like to do some tweaks on a telnet session as I have no control over
the server side what so ever.

However I cannot correctly negotiate a telnet connection to the server.

I've gone back to basics on the code for simplicity here;

Linux 2.6 : Python 2.3.4
Telnetlib Module - http://www.python.org/doc/2.3.4/lib/module-telnetlib.html

import sys, telnetlib
tn = telnetlib.Telnet("xxx.xxx.xxx.xxx")
tn.mt_interact()

All goes well if I point this code to telnet to 127.0.0.1 (Login etc)

However if I point the code to telnet to the server I get;
Debian GNU/Linux 3.0 xxx.xxx.org
Error opening terminal: network.
Note - telnet from the console to this address works fine.

I have limited knowledge of telnet/terminals however I am beginning to
think that the "server" is trying to negotiate a terminal type
(vt100/vt220 I think) and telnetlib responds incorrectly/not at all.

Any thoughts would be much appreciated / is there a more suitable library
than telnetlib for my purpose?

Many thanks ..... Svha
 
S

Svha

My bad - omitted the set_debuglevel() output from the above post ...
Hey it was a Friday afternoon ;)
Telnet(xxx.xxx.org,23): recv "\xff\xfd\x18\xff\xfd \xff\xfd#\xff\xfd'"
Telnet(xxx.xxx.org,23): IAC DO 24
Telnet(xxx.xxx.org,23): IAC DO 32
Telnet(xxx.xxx.org,23): IAC DO 35
Telnet(xxx.xxx.org,23): IAC DO 39
Telnet(xxx.xxx.org,23): recv '\xff\xfb\x03\xff\xfd\x01\xff\xfd\x1f\xff\xfb\
x05\xff\xfd!'
Telnet(xxx.xxx.org,23): IAC WILL 3
Telnet(xxx.xxx.org,23): IAC DO 1
Telnet(xxx.xxx.org,23): IAC DO 31
Telnet(xxx.xxx.org,23): IAC WILL 5
Telnet(xxx.xxx.org,23): IAC DO 33
Telnet(xxx.xxx.org,23): recv '\xff\xfb\x03'
Telnet(xxx.xxx.org,23): IAC WILL 3
Telnet(xxx.xxx.org,23): recv '\xff\xfb\x01'
Telnet(xxx.xxx.org,23): IAC WILL 1
Telnet(xxx.xxx.org,23): recv 'Debian GNU/Linux 3.0 x.x.org\r\nError opening'
Debian GNU/Linux 3.0 xxx.xxx.org
Error openingTelnet(xxx.xxx.org,23): recv ' terminal: network.\r\n'
terminal: network.

Svha
 
E

Eddie Corns

Svha said:
Greetings
I'd like to do some tweaks on a telnet session as I have no control over
the server side what so ever.
However I cannot correctly negotiate a telnet connection to the server.
I've gone back to basics on the code for simplicity here;
import sys, telnetlib
tn = telnetlib.Telnet("xxx.xxx.xxx.xxx")
tn.mt_interact()
All goes well if I point this code to telnet to 127.0.0.1 (Login etc)
However if I point the code to telnet to the server I get;
Debian GNU/Linux 3.0 xxx.xxx.org
Error opening terminal: network.
Note - telnet from the console to this address works fine.
I have limited knowledge of telnet/terminals however I am beginning to
think that the "server" is trying to negotiate a terminal type
(vt100/vt220 I think) and telnetlib responds incorrectly/not at all.
Any thoughts would be much appreciated / is there a more suitable library
than telnetlib for my purpose?

telnetlib support for this is minimal. Basically, you'll need to implement
the negotiation yourself using the option_callback() method. Look at
http://www.faqs.org/rfcs/rfc1091.html for the gory details on what's expected.
The negotiation could get quite complex in principle. One of the other
options it's asking about is for X-server, you may have to deal with that
too.

I've done a small amount of work in this area so I may be able to help, if you
get stuck send me mail.

Eddie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top