Operating System - HP-UX
1821831 Members
3513 Online
109638 Solutions
New Discussion юеВ

Re: strange characters in terminal ( reset terminal )

 
SOLVED
Go to solution
Bill McNAMARA_1
Honored Contributor

strange characters in terminal ( reset terminal )

How's it going all?!
you know when you cat a binary file and it messes up your terminal.. well, usually I just log out and log back in, but was wondering if there was a better way to clear it up.
I tried the reset command and resourcing profile but was still getting strange characters when typing.

Sometimes too I get a block capital problem that I can only solve by logging out and relogging back in. Is it the getty that's messed up or terminal settings?.. and why!?

Later,
Bill
It works for me (tm)
9 REPLIES 9
James R. Ferguson
Acclaimed Contributor
Solution

Re: strange characters in terminal ( reset terminal )

Hi Bill:

# stty sane

...should fix a lot...

Regards!

...JRF...
Ravi_8
Honored Contributor

Re: strange characters in terminal ( reset terminal )

Hi, Bill

JRF is right, i did the same "stty sane" when i was facing this problem.
never give up
Bill McNAMARA_1
Honored Contributor

Re: strange characters in terminal ( reset terminal )

so what does reset do that's different?

Thanks,
Bill
It works for me (tm)
Steve Post
Trusted Contributor

Re: strange characters in terminal ( reset terminal )

The following is from when I have used aix, sun, sco, and hpux. This is far from official. Its just what I have seen over the years.

A lot of times control-L will clean the screen.
Your problem is an ascii character went to the screen that the terminal could not display correctly. So your session decides to use a terminal type of vt100 or ANSI.
You can try this. It may not work.
While your screen is gobly-gook...

stty sane (the other guys are right)
TERM=vt100;export TERM
control-L
clear

steve
Curtis Larson_1
Valued Contributor

Re: strange characters in terminal ( reset terminal )

usually it is caused by reading your terminal's "shift out" character, ctrl-n. this switches to your terminal's secondary character set, usually the line drawing characters. the easiest way is to to a "shift in", echo "ctrl-o". and as i have a hard enough time typing ctrl characters when i can "see" what i'm typing, I'd recommend something like aliasing or making a shell function that has an easier name to type.
Curtis Larson_1
Valued Contributor

Re: strange characters in terminal ( reset terminal )

in the case of the upper case only characters at login. I believe that is left over from the teletype days. If the user name is all capitals it assumes that everything it receives will be capitalized and maps everything to uppercase characters. to correct the getty needs to end/respawn, your 3 incorrect login attempts, and be rerun by init. or you can login else where and kill the getty and it will respawn.
Darrell Allen
Honored Contributor

Re: strange characters in terminal ( reset terminal )

If using CDE and a dtterm, "Options - Reset - Soft Reset" will generally get my terminal back to normal.

What often happens to me is the escape sequence for setting a graphics (line draw) font is echoed to the terminal (because it just happened to be in the file I was cat'ing). That particular sequence is "Esc(0" which can be reset with "Esc(B".

Try typing this in a terminal:

echo "\033("0
echo "\033("B

The first (that's a zero on the end) will set line draw. The second will set you back in ascii mode. You won't be able to tell what you're typing on the second line unless you can read line draw stuff.

This works for me in xterm, dtterm, and vt100 sessions. And since xterm and vt100 don't give me a menu option for a reset it sometimes comes in handy.

Lots of other "useless" escape sequences are listed in the dtterm terminal emulation help screen.

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Bill Hassell
Honored Contributor

Re: strange characters in terminal ( reset terminal )

The problem is that terminals (especially HP) and wannabe's (terminal emulators) are not simple text devices. There are hundreds of special codes, usually starting with ESC, which can change settings and behaviors in the terminal. So cat'ing a binary file (like an executable or library file) can hit the terminal with a bunch strange codes.

The best way to reset the terminal is to use the tput command as in: tput reset. tput is not well known but it handles the hundreds of differences between different types of terminals. tput reset save a lot of clicking on terminal emulators to get them reset, or on-screen configs for real terminals.

It's not a bad idea to put tput reset into /etc/profile and /etc/csh.login files. Be sure to protect tput and programs like stty and ttytype so they don't get executed when there is no controlling tty (like a cron job).


Bill Hassell, sysadmin
Darrell Allen
Honored Contributor

Re: strange characters in terminal ( reset terminal )

Hi again,

To Bill Hassell: could you provide some more info on using "tput reset"? It does something to my terminal session though I can't tell what. It returns my prompt after about 2 seconds but it's the same as before the command. That is, if my session is set to use line draw characters (either from Esc(0 or Ctrl N) it is still in that mode after "tput reset".

Thanks,

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)