HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

setting TERM variables so that they still persist after logging out

 
Sab Ruprai
Occasional Visitor

setting TERM variables so that they still persist after logging out

Hello All

I am trying to set the TERM variable on our HP 11.11 machines to xterm.
I can issue #set TERM=xterm, #TERM=xterm and all works ok but settings revert to TERM=sun once I log out.

I have also changed the .profile setting from:-

# Set up the terminal:
if [ "$TERM" = "" ]
then
if /bin/i386
then
TERM=sun-color
else
TERM=sun
fi
export TERM
fi

TO:

# Set up the terminal:
if [ "$TERM" = "" ]
then
eval ` tset -s -Q -m ':?hp' `
else
eval ` tset -s -Q `
fi

but even with set and env set to TERM-xterm it still reverts to TERM=sun when I log out.

How can I set the TERM=xterm so it stays permanent. If TERM=sun, scrolling on teh terminal is not working properly.

Thank you

Regards
2 REPLIES
OldSchool
Honored Contributor

Re: setting TERM variables so that they still persist after logging out

the answer is going to vary. If you're using X-Windows, check the .dtprofile and see this post regarding DTSOURCEPROFILE

http://forums13.itrc.hp.com/service/forums/questionanswer.do?threadId=1384214

you may need to examine the value of $TERM just prior to you "new" statements:
# Set up the terminal:
if [ "$TERM" = "" ]
then
eval ` tset -s -Q -m ':?hp' `
else
eval ` tset -s -Q `
fi

As, if it's already set, it won't run

Such code may already exist in the system-wide file /etc/profile.

and, of course, if you're using something other then the normal POSIX / Ksh shells, other start up files could (or would) come into play as well
Bill Hassell
Honored Contributor

Re: setting TERM variables so that they still persist after logging out

The problem is with this line:

if [ "$TERM" = "" ]

You never want to accept TERM from an outside source. There is a little known feature (RFC 1091) of telnet that most Unix system use and that is the terminal type subcode 24. Back in the late 1980's, this was thought to be useful when there were just a few well-defined terminal types. Today, you should never use the incoming terminal type (set before login). In your case, your local system is lying to HP-UX -- as far as I know, there is no "sun" terminal, just as there is no "linux" terminal.

HP-UX had the foresight to provide a tool to handle the dozens and dozens of terminals automatically. The program is called ttytype and you can see what it does with this command line:

ttytype -s

ttytype will query the telnet line asking the terminal to identify itself. The correct way to set the TERM (and LINES and COLUMNS and ERASE) variable is to rip out *ALL* the code in /etc/profile and .profile which tests for "$TERM" = "". Instead, the *only* TERM setup line will be:

eval $(ttytype -s)

Now, regardless of how a user connects to your system (xterm, hpterm, dtterm, PuTTY, SecureCRT, Reflection, QCterm, hyperterminal, or even a real terminal like a Wyse 50 or an HP 700/92, etc) the TERM variable (and related terminal characteristics) will be set correctly. Note that when you do not use a 'real' terminal such as xterm, resizing the terminal window can be problematic on older systems that do not support SIGWINCH, a special signal indicating that the LINES and COLUMNS variables need to be updated. The command:

eval $(resize)

will update the LINES and COLUMNS values to match the new window size.

In all cases, success in using vi is completely dependent on obtaining TERM, LINES, COLUMNS and ERASE correctly. AS you might guess, setting these automatically is the only sane way to do this.


Bill Hassell, sysadmin