Operating System - HP-UX
1752346 Members
5789 Online
108787 Solutions
New Discussion юеВ

Re: Console keeps resetting to "hp" when using vt100

 
SOLVED
Go to solution
yaplej
Advisor

Console keeps resetting to "hp" when using vt100

I just got a vt100 interface for our KVM switch, and am having trouble getting it to work with our rp5400 hosts.

In root .profile we have this
if [ "$TERM" = "" ]
then
eval ` tset -s -Q -m ':?hp' `
else
eval ` tset -s -Q `
fi

We have changed ?hp to ?vt100, and that will work when running the command manually, but not when you logoff, and back on.

We also have /etc/profile
# set term if it's not set

# if [ "$TERM" = "" -o "$TERM" = "unknown" -o "$TERM" = "dialup" \
# -o "$TERM" = "network" ]
# then
# eval `ttytype -s -a`
# fi

# export TERM
if [ -z "$TERM" ]
then
case $TERM in

50) TERM=wy50
;;
50+) TERM=wy50
;;
wy50|vt100|vt220) : #do nothing
;;
*) eval `tset -s -Q ` #look in ttytype
if [ -z "$TERM" -o "$TERM" = "unknown" ]
then
eval ` tset -s -Q -m ':?wy50' `
fi
;;
esac
fi


We did not change anything in /etc/profile.

Then we also have /etc/csh.login with
if ( ! $?TERM ) then # if TERM is not set,
setenv TERM hp # use the default
endif

Our GSP is already set at VT100, and everything works great after we manually change $TERM to "vt100". So what do I need to fix for it to automatically choose vt100?

Thanks.
10 REPLIES 10
yaplej
Advisor

Re: Console keeps resetting to "hp" when using vt100

I change these lines in /etc/profile, and it seems to be working ok now.

*) eval `ttytype -s -a` #look in ttytype
if [ -z "$TERM" -o "$TERM" = "unknown" ]
then
eval ` tset -s -Q -m ':?vt100' `
Bill Hassell
Honored Contributor

Re: Console keeps resetting to "hp" when using vt100

This code in /etc/profile and .profile has been deprecated for years. First, the value of $TERM is often set by a totally unrelated system through the protocol (ie, telnet subcodes). So TERM might be set to "linux" or "hp" but with no relationship to your HP-UX system and the contents of the terminfo database in /usr/lib/terminfo. This profile code was written in the late 80's when all the systems that talked to each other (ie, no Linux, etc) were HP-UX.

The second problem is the 20 year old tset command that is lousy at identifying terminals (well, today they are emulators). So the fix is to *SCRAP ALL* of that code starting at the

if [ "$TERM" ]
or
if [ -z "$TERM" ]

and replace it with this simple incantation:

eval $(ttytype -s)

ttytype will identify ancient and modern terminals (and emulators) by using the 3 major categories of terminal family (Wyse, HP and VT/ANSI) model queries. You'll see the the queries as they timeout (1 sec each) when you run the command manually:

# ttytype -s
TERM='vt100'; export TERM;
LINES=24; export LINES;
COLUMNS=80; export COLUMNS;
ERASE='^?'; export ERASE;

And if the use of scummy csh is not optional, the code looks exactly the same for csh.login:

eval $(ttytype -s)

Now all will be well through network logins. And although ttytype is a great tool, the man page still has the obsolete test for $TERM already set. ALWAYS test the terminal at login and never hardcode TERM=something unless ttytype -s cannot identify your device.

Oops: Enter the GSP and MP.

Prior to the GSP/MP interface to the system hardware (ie, the classic console), ttytype worked flawlessly. But with very questionable designs in the GSP/MP code, cursor controls (and thus terminal compatibility issues) crept in (vfp is an example). But the GSP/MP could not automatically identify the terminal so two hardcoded settings were part of the GSP/MP, hp and vt100. So far so good as long as the console device matched the hardcoded GSP/MP setting.

But somewhere around 10.20/11.00 releases, the ttytype (and tset) code was changed to stop querying the console device and instead hardcode TERM to the GSP/MP value. So regardless of the type of terminal connected to the console, it is now ignored. I am sure the designers were trying to accommodate multiple connections through the LAN interface, but this would have been unnecessary if special escape sequences (cursor control, clear screen, etc) were dropped in favor of POA (Plain Old ASCII).

So we're stuck with a special case for all console connections. While I love the smart terminal features of the HP terminals and hpterm (upon which the PCL printer language is based), the momentum of the truly dumb terminal vt100 is too pervasive so it's time to drop real HP terminals (and emulators such as QCTerm and Reflection/HP) and lose the 2-line softkey labels and plethora of character enhancements. This recommendation is only for sysadmins that must by necessity be connected to the real console. Normal users can always run Wyse, HP, Tektronix, whatever on non-console connections.

So set all your GSP/MP interfaces to vt100 and adopt a smart vt100 emulator such as PuTTY. There are many "vt100" emulators out there, some are very expensive and some (like PuTTY) are free. In conjunction with a PuTTY config manager, you can easily handle hundreds of machines and the occasional DEL vs BS issue which is resolved in PuTTY settings.


Bill Hassell, sysadmin
Bill Hassell
Honored Contributor

Re: Console keeps resetting to "hp" when using vt100

> I wrote: ...looks exactly the same for csh.login:

My apologies to csh users...the syntax is simply:

eval ttytype -s

One additional note about the changes in ttytype:

If you run the command ttytype -s on the GSP/MP, you may see it truncated:

# ttytype -s
TERM='vt100'; export TERM;
ERASE='^?'; export ERASE;

Most experienced sysadmins will run at least 132 column screens to handle long lines. But try to login through the console and you won't get COLUMNS and LINES updated. That will break vi and many other menu programs.

You need to follow ttytype with resize which thankfully, was not hacked for the GSP/MP interface (it's protected by Xwindows):

eval $(ttytpe -s)
eval $(/usr/bin/X11/resize)

or a 1-liner:

eval $(ttytype -s;/usr/bin/X11/resize)


Bill Hassell, sysadmin
yaplej
Advisor

Re: Console keeps resetting to "hp" when using vt100

So please dumb this down for me.

In /etc/profile just use:
eval $(ttytype -s;/usr/bin/X11/resize)

and in /etc/csh.login use:
eval ttytype -s;/usr/bin/X11/resize

Do I need to update all the .profile files in each of the users directories to also just use:
eval $(ttytype -s;/usr/bin/X11/resize)

?
Bill Hassell
Honored Contributor
Solution

Re: Console keeps resetting to "hp" when using vt100

Yes, the 1-liner should replace all the if [ "$TERM" ] code (the entire if-then-fi) in all the profiles (/etc/profile and $HOME/.profile). And csh.login too.

To propagate the change to any new users, also change .profile in /etc/skel. This directory is copied to each new user's $HOME directory using sam/smh or useradd.

However, since each user will go through /etc/profile, .profile doesn't need to run ttytype again. It will delay login slightly.

If you are using (or plan to use) batch jobs that use su - to change user, you'll need to protect the terminal-only commands such as:

ttytype
tput
stty
tabs

There is a command: tty
that will return 0 when the session is connected to a real terminal. Something like this:

if tty
then
eval $(ttytype -s;/usr/bin/X11/resize)
tabs
stty erase "^H" kill "^U" intr "^C" eof "^D"
stty -parity ixoff susp \^Z dsusp \^Y
cat /etc/motd
echo "See copyright notice at: /etc/copyright"
export PS1='# '

fi

The above code will keep a lot of junk messages from showing up in syslog and email.


Bill Hassell, sysadmin
yaplej
Advisor

Re: Console keeps resetting to "hp" when using vt100

So in /etc/csh.login would the code look like this?

if tty
then
eval ttytype -s;/usr/bin/X11/resize
tabs
stty erase "^H" kill "^U" intr "^C" eof "^D"
stty -parity ixoff susp \^Z dsusp \^Y
cat /etc/motd
echo "See copyright notice at: /etc/copyright"
export PS1='# '

fi
James R. Ferguson
Acclaimed Contributor

Re: Console keeps resetting to "hp" when using vt100

Hi:

Replace:

# if tty

With:

# if [ -t 0 ]

This tests STDIN (file descriptor 0) to determine if it is associated with a 't'erminal.

Regards!

...JRF...
yaplej
Advisor

Re: Console keeps resetting to "hp" when using vt100

Thank you so much for your help. Here is what we ended up with. We are putting this on our backup/test host to make sure it works, and then will copy it to our live host. We are also going through all the users in /home to remove any TERM code in their .profile file.

in /etc/profile

if tty
then
eval $(ttytype -s;/usr/bin/X11/resize)
tabs
stty erase "^H" kill "^U" intr "^C" eof "^D"
stty -parity ixoff susp \^Z dsusp \^Y
echo "Value of TERM has been set to \"$TERM\". "
cat /etc/motd
echo "See copyright notice at: /etc/copyright"
export PS1='# '

fi



in /etc/csh.login

if [ -t 0 ]
then
eval ttytype -s;/usr/bin/X11/resize
tabs
stty erase "^H" kill "^U" intr "^C" eof "^D"
stty -parity ixoff susp \^Z dsusp \^Y
echo "Value of TERM has been set to \"$TERM\". "
cat /etc/motd
echo "See copyright notice at: /etc/copyright"
export PS1='# '

fi
WWarren
Advisor

Re: Console keeps resetting to "hp" when using vt100

I'm no expert in csh (it's a pain), but ttytype seems to produce incorrect output for csh if $ERASE is supposed to be DEL:

$ ttytype -s
setenv TERM vt320;
setenv LINES 24;
setenv COLUMNS 80;
setenv ERASE ^?;

The last statement will produce an error as the question mark isn't quoted. Tested in 11.00 and 11.23. Maybe there's an easy work-around I'm overlooking?