Telnetlib & Term Types

Eddie Corns eddie at holyrood.ed.ac.uk
Mon Nov 22 07:55:23 EST 2004


Svha <news at svha.demon.co.uk> writes:

>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?

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



More information about the Python-list mailing list