displaying extended ASCII from a telnet session

Terry Reedy tjreedy at udel.edu
Fri Jan 9 21:25:02 EST 2004


"Christian Wilcox" <cwilcox at etcconnect.com> wrote in message
news:mailman.229.1073667874.12720.python-list at python.org...
>I'm trying to programmatically access information from a telnet session
which is >normally accessed with a telnet program capable of terminal
emulation (currently set at >VT320).  The initial login text displays fine,
of course, but when I get to the section >which displays extended ASCII
characters, Telnet from telnetlib displays the following >garbled mess:

There may or may not be any 'extended' chars, but there are 'undisplayable'
chars, signaled by most of the '?'s (although a few might be real).
The '?' before '[' is the Escape char (what the Esc key on upper left
generates.).  What follows are VTxxx escape sequences, which often start
with <esc>[.

>?[?40h?[?3l?[0;1m?>?[?1l?[?25l?[?3l?[0;0H?[2J?[?25l?(B??[0;7m?[23B ba6.0
version 03-1993/R1 ?[0m?[0;
.....
>Any ideas of a way to decode this information?

Since the escape sequences are about visual formating and not about
content, you probably do not need to as long as you can recognize and
discard what for you may really be noise.  To make it easier, you might be
able to the the system that you are a really dumb pre-VT100 terminal that
only understands control chars and not the newer (as of about 2 decades
ago) control sequences.  On *nix, this might just mean resetting the TERM
environment variable.  But some programs might only talk to clients that
are VT100 capable.

Another route entirely.  Terminal and telnet programs often have a script
capability with commands like "when you receive 'sometext', send 'mytext'"
and others to turn saving to a disk file on and off.

Or, if you can install programs on the target, perhaps you can get at the
info directly withoug virtual screen scraping and just email yourself a
file in the format you want.

Terry J. Reedy





More information about the Python-list mailing list