How do you restore the display after 'cat'-ing a file that distorts it?

How do you restore the display after 'cat'-ing a file that distorts it?

Post by Tony Curti » Fri, 03 Dec 1999 04:00:00




>  I have several Unix boxes running HP-UX 10.20, Sun Solaris 2.6, and
> Redhat Linux 6.0 in various configurations. Sometimes my display will
> distort if I accidently 'cat' a bad file, or a binary file, or a print
> output file that has control chracters in it. By "distort" I mean the
> characters on my screen will be unreadable
> garbage.  ...
> Exceed program to connect to my boxes using X-terminal sessions, but I

You need to tell the xterm to reset.  You can do
this through the Ctrl-Middle-mouse chord to get the
menu, choose "Full Reset".

I presume this is the same as sending the hard reset
string as defined for xterm in the term{cap,info}
file (but i'm on a you-know-what laptop and don't
have xterm to test).

hth
tony

 
 
 

How do you restore the display after 'cat'-ing a file that distorts it?

Post by Lokesh Seti » Fri, 03 Dec 1999 04:00:00


Close your eyes, pray to god, and type this:

/bin/echo "\033c"

or

echo <Ctrl-V><Esc>c

and hopefully you'll see your prompt again :).

Regards,
Lokesh.

    Craig>  I have several Unix boxes running HP-UX 10.20, Sun Solaris
    Craig> 2.6, and Redhat Linux 6.0 in various
    Craig> configurations. Sometimes my display will distort if I
    Craig> accidently 'cat' a bad file, or a binary file, or a print
    Craig> output file that has control chracters in it. By "distort"
    Craig> I mean the characters on my screen will be unreadable
    Craig> garbage. The commands that I type in continue to operate
    Craig> properly, but they are not displayed in the correct
    Craig> format. Is there a command to restore the terminal screen
    Craig> to the proper settings when this occurs? I am using the
    Craig> Hummingbird Exceed program to connect to my boxes using
    Craig> X-terminal sessions, but I have seen this problem happen at
    Craig> the console screen as well. Usually, if I log out of the
    Craig> box and right back in, the display is restored. I would
    Craig> much rather run a script or command that would do this
    Craig> immediately. Any help or direction to a man page or
    Craig> documentation would be appreciated.

    Craig> -Craig

--
When we come back, I'll drop a line. (The Doors)

 
 
 

How do you restore the display after 'cat'-ing a file that distorts it?

Post by Jack Perd » Fri, 03 Dec 1999 04:00:00



> I have several Unix boxes running HP-UX 10.20, Sun Solaris 2.6, and
>Redhat Linux 6.0 in various configurations. Sometimes my display will
>distort if I accidently 'cat' a bad file, or a binary file, or a print
>output file that has control chracters in it. By "distort" I mean the
>characters on my screen will be unreadable garbage. The commands that
>I type in continue to operate properly, but they are not displayed in
>the correct format. Is there a command to restore the terminal screen
>to the proper settings when this occurs? I am using the Hummingbird
>Exceed program to connect to my boxes using X-terminal sessions, but I
>have seen this problem happen at the console screen as well. Usually,
>if I log out of the box and right back in, the display is restored. I
>would much rather run a script or command that would do this
>immediately. Any help or direction to a man page or documentation
>would be appreciated.

You can try "reset"... might help.

jack

 
 
 

How do you restore the display after 'cat'-ing a file that distorts it?

Post by Colin Smit » Fri, 03 Dec 1999 04:00:00



>  I have several Unix boxes running HP-UX 10.20, Sun Solaris 2.6, and
> Redhat Linux 6.0 in various configurations. Sometimes my display will
> distort if I accidently 'cat' a bad file, or a binary file, or a print
> output file that has control chracters in it. By "distort" I mean the
> characters on my screen will be unreadable garbage. The commands that

[snip]

Try "tput reset".

--
Colin Smith

 
 
 

How do you restore the display after 'cat'-ing a file that distorts it?

Post by Tony Curti » Fri, 03 Dec 1999 04:00:00




> >/bin/echo "\033c"
> >echo <Ctrl-V><Esc>c

>  Both of these methods worked for me. Thanks. Now, the next time my
> screen freaks out and I use these key combinations to reset it,
> someone will ask me "what does that do?". How can I explain what is
> happening when I do this?

It's sending the "reset" string to the terminal.
Which is presumably what the Ctrl-Mouse thing does
too.  "man terminfo" for more info on terminal
control.

hth
tony

 
 
 

How do you restore the display after 'cat'-ing a file that distorts it?

Post by Mike Stroy » Fri, 03 Dec 1999 04:00:00


| Both of these methods worked for me. Thanks. Now, the next time my
|screen freaks out and I use these key combinations to reset it,
|someone will ask me "what does that do?". How can I explain what is
|happening when I do this?

  You probably sent a ctrl-N to the terminal, choosing the alternate
font.  The hard reset would switch back to the default font.  You can
also use ctrl-O character to change back, like-

echo ctrl-O

  Some shells will echo ctrl-O back as "^O" as you type it.  The echo
should take care of that.

--

 
 
 

How do you restore the display after 'cat'-ing a file that distorts it?

Post by Lokesh Seti » Sat, 04 Dec 1999 04:00:00




> >/bin/echo "\033c"
> >echo <Ctrl-V><Esc>c

>  Both of these methods worked for me. Thanks. Now, the next time my
> screen freaks out and I use these key combinations to reset it,
> someone will ask me "what does that do?". How can I explain what is
> happening when I do this?

A terminal (physical or emulated) understands "Control signals". These
control signals are usually implemented in terms of Escape
Sequences. When you write these Escape sequences to a terminal, they
are not written to the screen, but the terminal driver takes special
actions for these sequences. In fact, we use most of these sequences
everyday, but don't notice it. For e.g., when you use vi, and say go
one line up, the whole screen is not written (it would be too slow),
but a special "escape sequence" is sent which asks the driver to move
the cursor to the specific location.

Here, "Esc c" is the sequence to reset a terminal. It is fairly
portable among different terminals (vt100, xterm...). To write the
"esc" character, we need to prefix it with <Ctrl-V>, so that the <esc>
character is taken literally.

So echo <Ctrl-V><Esc>c works.
The octal code for Esc is 033, so in principle echo "\033c" also
works, but some inbuilt echo programs (like in bash) do not honour the
backslashed things like \033 unless you give the option -e.
So, I wrote /bin/echo "\033c" instead of only echo "\033c" so that the
binary in /bin will be executed instead of the shell built-in.

Regards,
Lokesh.

--
When we come back, I'll drop a line. (The Doors)

 
 
 

How do you restore the display after 'cat'-ing a file that distorts it?

Post by Richard S. Shufor » Mon, 06 Dec 1999 04:00:00



> Sometimes my display will distort if I accidently 'cat' a bad file,
> or a binary file, or a print output file that has control chracters
> in it....the characters on my screen will be unreadable garbage....
> Is there a command to restore the terminal screen to the proper
> settings when this occurs?

and Lokesh Setia offered help:
:
: ..."Esc c" is the sequence to reset a terminal. It is fairly
: portable among different terminals (vt100, xterm...)

The  Escape c  control sequence is the ANSI-X3.64/ISO-DP6429
"RIS" or Hard Terminal Reset.  If this 2-octet sequence is
executed on a terminal or emulator that follows the standard
(which the xterm emulation does), then the effect is to reload
all "power-on" default terminal settings.  (Or to restore NVR/
Non-Volatile RAM settings, if the terminal has those, as on a
DEC VT420.)

If you want a less drastic type of reset, you could "cat" a
short file to your screen containing controls that reset only
the most frequently damaged terminal settings (including the
alternate character set).  I constructed such a file a few
years ago; you can get it from:

    http://www.cs.utk.edu/~shuford/terminal/cls.uue

This is part of a collection of information on video terminals:

    http://www.cs.utk.edu/~shuford/terminal_index.html

 ...Richard S. Shuford
--
Stratus Computer, Maynard, Massachusetts  http://www.stratus.com/  
Duplex-hardware fault-tolerant computer systems running VOS or HP-UX.
This message does not contain the official opinion of Stratus.

 
 
 

How do you restore the display after 'cat'-ing a file that distorts it?

Post by Francois Laupretr » Tue, 07 Dec 1999 04:00:00


Type '<Ctrl-J>stty sane<Ctrl-J>'.

It should reset a 'normal' behaviour. And it works with any type of terminal
(xterm, console, ...). It is described in the 'stty' man page.

 
 
 

How do you restore the display after 'cat'-ing a file that distorts it?

Post by Bernard Chandle » Tue, 07 Dec 1999 04:00:00




> >and Lokesh Setia offered help:
> :
> : ..."Esc c" is the sequence to reset a terminal. It is fairly
> : portable among different terminals (vt100, xterm...)

> The  Escape c  control sequence is the ANSI-X3.64/ISO-DP6429
> "RIS" or Hard Terminal Reset.  If this 2-octet sequence is
> executed on a terminal or emulator that follows the standard
> (which the xterm emulation does), then the effect is to reload
> all "power-on" default terminal settings.  (Or to restore NVR/
> Non-Volatile RAM settings, if the terminal has those, as on a
> DEC VT420.)

> If you want a less drastic type of reset, you could "cat" a
> short file to your screen containing controls that reset only
> the most frequently damaged terminal settings (including the
> alternate character set).  I constructed such a file a few
> years ago; you can get it from:

>     http://www.cs.utk.edu/~shuford/terminal/cls.uue

> This is part of a collection of information on video terminals:

>     http://www.cs.utk.edu/~shuford/terminal_index.html

>  ...Richard S. Shuford
> --
> Stratus Computer, Maynard, Massachusetts  http://www.stratus.com/
> Duplex-hardware fault-tolerant computer systems running VOS or HP-UX.
> This message does not contain the official opinion of Stratus.

I find i get results with
stty sane and control j