How could I set term at login

Daniel A. Glasser dag at persoft.com
Fri Feb 22 04:46:52 AEST 1991


Assuming that you are always (or at least, usually) talking to DEC
(or compatible) terminals or emulators thereof, there's a simple way
to do this.  Write a program that sends the DA (Device Attributes) control
sequence, "<ESC>[c".  The terminal will respond with a report which identifies
the terminal family and gives a list of what it can do.

The VT100 responds with "<ESC>[?<n;m>c" where <n;m> is a decimal string
with value < 60, usually followed by a semicolon and another decimal string
which identifies a bit more about the terminal.

	VT100 w/printer:	<ESC>[?1;2c
	VT101			<ESC>[?1;0c
	VT102			<ESC>[?6c

and so on.  If what you are interested in is VT100 level vs. VT200+ level,
you should just pay attention to the first decimal parameter after the
question mark.  VT200 level terminals will respond with a sequence
where the first decimal parameter is >= 60.  A VT220 or VT240 will have 62
here, a VT3[234]0 will have 63, a VT420 has 64.  On these terminals, the
decimal values that follow the first semicolon list some of the features
of the terminal sending the report.

The features listed for DEC VT[234]xx terminals include:

	1	132 column support (EVO on VT100, I think)
	2	Printer port installed
	3	ReGIS display
	4	SIXEL graphics I/O
	6	Selective Erase (DECSEL/DECSED/DECSCA support)
	7	Downloadable Character Set (DRCS)
	8	User Defined Keys (UDK)
	9	National Replacement Character sets (NRCs)
	15	DEC Technical Character Set
	18	Windowing (split screen) capability
	19	Dual Sessions
	21	Horizontal Scrolling

(I got these from looking in the VT240 and VT420 manuals, there are
 many others, including locator device support, etc.)

Your program should send the DA request, and then wait for a response
for a very short time (maybe based on baud rate).  If no response is
received, send the string "<ESC>\" to the terminal just in case it is
a REAL VT52, which would be put in no-scroll mode by the "<ESC>[" of the
DA request.  (You may also want to then send the string "<ESC>Z" and see
if you get "<ESC>\z" back, since that's the VT52 response to the DECID
sequence.)

Based on what (if anything) your program got, you should write (to stdout)
the terminal type desired.  This then gets used in a .login or .profile
script as
	(.login)	setenv TERM 
	(.profile)	TERM=`/usr/local/bin/dectermtype` ; export TERM

I will leave the writing of this program as an exercise for the reader.
Note that you should NOT simply match the string the terminal sends
against a table of predefined strings, since various flavours of various
DEC terminal family terminals (and emulators thereof) report different
features.  Also, make sure you read the entire report (up to and including
the 'c' at the end) if you see any of it, otherwise the remainder of the
report might end up causing future problems.  Also, read this with echo
turned off for best results.

I hope this helps.

-- 
          Daniel A. Glasser  |  Persoft, Inc.  |  dag at persoft.com
                "Their brains were small, and they died."



More information about the Comp.unix.admin mailing list