- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Term = HP
Operating System - HP-UX
1753914
Members
9198
Online
108810
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-23-2007 08:31 PM
тАО08-23-2007 08:31 PM
Re: Term = HP
while running su, you should care that if you will run su - user then only user's profile will execute. only su will not execute root user's profile.
It's kind of fun to do the impossible
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-24-2007 01:26 AM
тАО08-24-2007 01:26 AM
Solution
It is really important to let your profile determine your terminal characteristics, so NEVER code TERM=anything. HP-UX supplies a very capable program called ttytype that determines what terminal you are using and what values should be used for COLUMNS and LINES. Users are no longer using 'real' terminals (ie, green screens or glass teletypes), but are instead running a plethora of imitators called terminal emulators. They may be truly primitive (dumb) terminal emulators such as Hyperterminal, freeware such as PuTTY or QCterm, or commercial products such as SecureCRT or WRQ Reflection products. Complicating this even more are GUI users that run Xwindows on their PC (Hummingbird, WRQ's Reflection/X, or similar, and the terminal window is really 'borrowed' from the server in the form of xterm, dtterm or hpterm.
It's important to *always* run ttytype in /etc/profile, and remove the profile code that says something like this:
if [ "$TERM" = "" ]
then
eval ` tset -s -Q -m ':?hp' `
else
eval ` tset -s -Q `
fi
or this:
# set term if it's not set
if [ "$TERM" = "" -o "$TERM" = "unknown" -o "$TERM" = "dialup" \
-o "$TERM" = "network" ]
then
eval `ttytype -s -a`
fi
The above comment says: set term if it's not set which may have been relevant 25 years ago when all connections were 'real' terminals. But a telnet session may (or may not) carry a terminal ID when a user logs in and there is nothing standard about the value of TERM coming from a non-HP-UX source. For instance, a Linux box may set TERM=linux or TERM=linux-80x25, clearly incompatible with HP's extensive (but not infinite) teriminfo library (found in /usr/lib/terminfo). This TERM setting comes in from the remote client at the start of the telnet session and therefore sets TERM before /etc/profile is started.
So to avoid painful mistakes, always ask ttytype to identify the terminal, regardless of whether it was already set. The important features must match the terminal emulator which is why you never hardcode the values. Terminal emulators are not accurate emulators. The most common emulation is vt100 yet 99% of the emulators allow things that are impossible on a DEC VT100 (see http://vt100.net/ in case you've never seen one), things like changing the columns to 132 or lines to 60, programmable softtkeys, etc. Because there are just so many different programs out there, it is best to always test each connection.
The following code should replace all the lines in /etc/profile that set the TERM, COLUMNS, LINES and ERASE:
if tty -s
then
# always set TERM
eval $(ttytype -s -a)
if [ "$TERM" = "" -o \
"$TERM" = "unknown" -o \
"$TERM" = "dialup" -o \
"$TERM" = "network" -o \
"$TERM" = "dumb" ]
then
export TERM=vt100
fi
stty erase "^H" kill "^U" intr "^C" eof "^D" 2> /dev/null
stty hupcl ixon ixoff 2> /dev/null
# set $ERASE to ^H, if ERASE is not set or set to DEL
# stty erase and $ERASE must match
if [ "$ERASE" != "^H" ]
then
export ERASE="^H"
stty erase $ERASE
fi
tabs
# Turn off the softkey labels 'cause they burn the terminal screens and
# are annoying when editing or watching commands and data...
# (no effect for non-softkey terminals)
# Also send an sgr0 (end enhancements) in case some
# feature like blink is ON for this terminal
tput rmln
tput sgr0
# Some vt100 emulators don't behave right and ttytype
# is unable to determine LINES or COLUMNS. Set a default
# if either one is unset or too small. LINES=4 is a bug
# in ttytype for 8bit VT220 emulators.
LINES=${LINES:-24}
COLUMNS=${COLUMNS:-80}
[ $LINES -le 4 ] && export LINES=24
fi
Once you use the above code, all users will be properly setup so things like vi and swinstall and SAM work correctly no matter what terminal they are using. Note that Xwindow users must enable /etc/profile processing with an .Xdefaults setting. Notice that all this code is protected by tty -s so when /etc/profile is run in batch mode (ie, cron, at, inittab, etc), the terminal-only commands will be bypassed.
And after all the above has been said, the GSP/MP throws a wrench into the middle of everything. For some unexplained reason, the GSP/MP firware designers decided to hardcode your terminal setting (VT100 or HPTERM) and even modified HP-UX code for ttytype to override your TERM settings, regardles of what terminal you are using at the console. So even if you run ttytype at the console, it may not set the correct values. Although I prefer HPTERM, the vast majority of new boxes (all models in the rx or rp product line) are hardcoded to VT100. The best advice: DON'T use the console except for simple commands. If you have to switch between VT and HP like I do, use an emulator that can quickly change emulation mode such as Reflection for HP (*not* Reflection/X).
Bill Hassell, sysadmin
It's important to *always* run ttytype in /etc/profile, and remove the profile code that says something like this:
if [ "$TERM" = "" ]
then
eval ` tset -s -Q -m ':?hp' `
else
eval ` tset -s -Q `
fi
or this:
# set term if it's not set
if [ "$TERM" = "" -o "$TERM" = "unknown" -o "$TERM" = "dialup" \
-o "$TERM" = "network" ]
then
eval `ttytype -s -a`
fi
The above comment says: set term if it's not set which may have been relevant 25 years ago when all connections were 'real' terminals. But a telnet session may (or may not) carry a terminal ID when a user logs in and there is nothing standard about the value of TERM coming from a non-HP-UX source. For instance, a Linux box may set TERM=linux or TERM=linux-80x25, clearly incompatible with HP's extensive (but not infinite) teriminfo library (found in /usr/lib/terminfo). This TERM setting comes in from the remote client at the start of the telnet session and therefore sets TERM before /etc/profile is started.
So to avoid painful mistakes, always ask ttytype to identify the terminal, regardless of whether it was already set. The important features must match the terminal emulator which is why you never hardcode the values. Terminal emulators are not accurate emulators. The most common emulation is vt100 yet 99% of the emulators allow things that are impossible on a DEC VT100 (see http://vt100.net/ in case you've never seen one), things like changing the columns to 132 or lines to 60, programmable softtkeys, etc. Because there are just so many different programs out there, it is best to always test each connection.
The following code should replace all the lines in /etc/profile that set the TERM, COLUMNS, LINES and ERASE:
if tty -s
then
# always set TERM
eval $(ttytype -s -a)
if [ "$TERM" = "" -o \
"$TERM" = "unknown" -o \
"$TERM" = "dialup" -o \
"$TERM" = "network" -o \
"$TERM" = "dumb" ]
then
export TERM=vt100
fi
stty erase "^H" kill "^U" intr "^C" eof "^D" 2> /dev/null
stty hupcl ixon ixoff 2> /dev/null
# set $ERASE to ^H, if ERASE is not set or set to DEL
# stty erase and $ERASE must match
if [ "$ERASE" != "^H" ]
then
export ERASE="^H"
stty erase $ERASE
fi
tabs
# Turn off the softkey labels 'cause they burn the terminal screens and
# are annoying when editing or watching commands and data...
# (no effect for non-softkey terminals)
# Also send an sgr0 (end enhancements) in case some
# feature like blink is ON for this terminal
tput rmln
tput sgr0
# Some vt100 emulators don't behave right and ttytype
# is unable to determine LINES or COLUMNS. Set a default
# if either one is unset or too small. LINES=4 is a bug
# in ttytype for 8bit VT220 emulators.
LINES=${LINES:-24}
COLUMNS=${COLUMNS:-80}
[ $LINES -le 4 ] && export LINES=24
fi
Once you use the above code, all users will be properly setup so things like vi and swinstall and SAM work correctly no matter what terminal they are using. Note that Xwindow users must enable /etc/profile processing with an .Xdefaults setting. Notice that all this code is protected by tty -s so when /etc/profile is run in batch mode (ie, cron, at, inittab, etc), the terminal-only commands will be bypassed.
And after all the above has been said, the GSP/MP throws a wrench into the middle of everything. For some unexplained reason, the GSP/MP firware designers decided to hardcode your terminal setting (VT100 or HPTERM) and even modified HP-UX code for ttytype to override your TERM settings, regardles of what terminal you are using at the console. So even if you run ttytype at the console, it may not set the correct values. Although I prefer HPTERM, the vast majority of new boxes (all models in the rx or rp product line) are hardcoded to VT100. The best advice: DON'T use the console except for simple commands. If you have to switch between VT and HP like I do, use an emulator that can quickly change emulation mode such as Reflection for HP (*not* Reflection/X).
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-24-2007 01:30 AM
тАО08-24-2007 01:30 AM
Re: Term = HP
And just a clarification, tset is deprecated (not recommended anymore). It was designed for a simpler time when terminals were connected to serial ports and they were 'real' terminals. The code and usage are quite convoluted -- use eval $(ttytype -s -a) as mentioned above.
Bill Hassell, sysadmin
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2007 12:19 PM
тАО08-27-2007 12:19 PM
Re: Term = HP
Thanks for all yr comments.I'll appreciate it
- « Previous
-
- 1
- 2
- Next »
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP