displaying extended ASCII from a telnet session

  • Thread starter Christian Wilcox
  • Start date
C

Christian Wilcox

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:

?[?40h?[?3l?[0;1m?>?[?1l?[?25l?[?3l?[0;0H?[2J?[?25l?(B??[0;7m?[23B ba6.0 version 03-1993/R1 ?[0m?[0;
7m?[1;2Hmtccom00000000?[1C ?[1C ?[1C ?[1C ?[
0m?[10;5H?(0?lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk?[11;5Hx?[68Cx?[1
2;5Hx?(B? License Code : 178241/105?[39C?(0?x?[13;5Hx?(B? Developed for:?[52C?(0?x?[14;5Hx?(B?
Electronic Theatre Controls?[39C?(0?x?[15;5Hx?[68Cx?[16;5Hmqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
x?(B??[60CChoice:s?[56C?(0?x?[1D?[1B(0?x?[1D?[1B ?[5C?(0?x?[1D?[1B

Any ideas of a way to decode this information?

Christian
 
S

Samuel Walters

|Thus Spake Christian Wilcox On the now historical date of Fri, 09 Jan
2004 11:04:27 -0600|
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:

Any ideas of a way to decode this information?

Tell us a bit more detail on your problem, such as what program/system are
you trying to get to access what program/system.

Unless you correct me, I'll assume that you're trying to get a python
program that may or may not be on a linux/unix computer to access a telnet
resource that you normally use a vt320 emulator to access.

The information you seek has to do with termcap, termio and (tangently)
curses. Each terminal defines a set of codes and capabilities using a
termcap file (on *nix, at least.) Those capabilities are stored in the
termcap database. Your terminal program is not properly decoding these
codes and control sequences. Specifically, the codes like ?[?40h are
control sequences. and the long lines of q's are where the server
told the terminal to use line-drawing characters rather than normal
characters. You, of course, only see q's because you aren't decoding the
stream.

Read up on the matter here:
http://www.gnu.org/software/termutils/manual/termcap-1.3/html_chapter/termcap_4.html#SEC23
and here:
http://www.gnu.org/software/termutils/manual/termcap-1.3/html_chapter/termcap_toc.html

But don't necessarily try to get a deep understanding of each element.
Just try to get an overview so that you have a grasp on the issues
involved. There are probably better manuals on this stuff, but these are
the definitive manuals.

Once you've done that and told us more about your problem, we'll be able
to have a much more informative discussion of how to resolve this issue.

HTH

Sam Walters.
 
T

Terry Reedy

Christian Wilcox said:
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 said:
?[?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
 

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
474,175
Messages
2,570,942
Members
47,490
Latest member
Finplus

Latest Threads

Top