Operating System - HP-UX
1827819 Members
3325 Online
109969 Solutions
New Discussion

Garbage characters when user telnets in

 
SOLVED
Go to solution
Robert Funk_1
Contributor

Garbage characters when user telnets in

Has anyone come across this issue before? I have one user account that when they telnet in to my HP, they see garbage characters and no prompt until they hit return. From that point on, they can work normally. See the attached screen shot to view exactly what I mean.
5 REPLIES 5
Leif Halvarsson_2
Honored Contributor

Re: Garbage characters when user telnets in

Hi,
What is the enviro variable TERM set to in the users .profile ?
Hein van den Heuvel
Honored Contributor

Re: Garbage characters when user telnets in


The sequence you show corresponds with trying to set TAB stops, probably from the 'tabs' command. See: man tabs.

Apparently your login scripts (/etc/profile? ~/.profile ? .cshrc ? ) uncoditionally blast the victims terminals.

You want to make this conditional. using something like (no solution, just hints):

if [ ! "$VUE" ]; then

# set term if it's not set

if [ "$TERM" = "" -o "$TERM" = "unknown" -o "$TERM" = "dialup" \
-o "$TERM" = "network" ]


Also check out ttytype and tset

Hein.

Steven E. Protter
Exalted Contributor

Re: Garbage characters when user telnets in

This can occur from corrupt pty variables.

insf -e has helped me in the past with this, I don't know why it works though.

Also if there is a particular pty thats bad, use rmsf on it first.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Hein van den Heuvel
Honored Contributor

Re: Garbage characters when user telnets in


For some environment scripts I also tty -s
For example:

tty -s
if ( $status == 0 ) stty erase "^?"

> they see garbage characters

That's not garbage... it just looks like garbage to the untrained eye :-)




Bill Hassell
Honored Contributor
Solution

Re: Garbage characters when user telnets in

These aren't garbage characters at all. They are escape sequences being sent to the terminal but the terminal doesn't recognize them, so the displayable characters are being shown. This is occuring somewhere after the mail check (which is usually in /etc/profile). If there isn't anything special at the end of profile, then it's in .profile. The codes start with [3g which is the code for clear-all-tab-stops. Now if you have TERM=vt100 or TERM=hp, tabs will not produce the codes you are seeing. So your value for TERM has been imporperly set.

DON'T hardcode TERM=something in .profile!! There are hundreds of terminals (and imitations that run on PCs called 'emulators') out there and most Unix systems are well equipped to handle them all using a library called Curses. Curses defines generic features (like clear screen and clear tabs) but translates these into terminal-specific strings based on the value of TERM. In your case, [3g can be found using:

untic vt100 | grep 3g
bel=^G, cr=\r, csr=\E[%i%p1%d;%p2%dr, tbc=\E[3g

where untic decodes all the codes for the vt100 terminal. You see \E[3g which translates to ESC (the escape charater) plus [3g and the generic feature is called tbc. In the man page for terminfo (very lengthy) you'll see that tbc is clear all tabs.

So start with:

echo $TERM

This setting is what tells the Curses library what terminal you have. Obviously, it doesn't match at all so it must have been hardcoded (or preset via telnet--more later). Remove any TERM= codes in .profile and replace it with:

eval $(ttytype -s)

As mentioned, you'll need to protect the ttytype command in case the login is run in batch mode (like su - username in a cron job). In batch mode, there is no controlling terminal, so you code it this way:

if tty -s
then
eval $(ttytype)
tput reset
tabs
fi

The code will only run if there is a real terminal login and sets TERM, COLUMNS, LINES and ERASE.

Depending on what you are using (a PC, a Mac, a Linux box, etc) the handshake during telnet login can set TERM automatically (but you don't want that at all!). Using a subcode in the telnet handshake, your local box can provide a string that will be used to preset TERM even before /etc/profile runs. The problem is that there is little chance that the string provided has any relationship to the terminfo database in HP-UX. So use ttytype to ID the terminal and set TERM automatically.

In the future, you can troubleshoot logins (ie, profile commands) by simply adding:

set -x

to /etc/profile and/or .profile which then traces each step of the script.


Bill Hassell, sysadmin