Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Unreadable text after cat binary file

324 views
Skip to first unread message

Andy Moreton

unread,
Feb 11, 1997, 3:00:00 AM2/11/97
to

I recently did a cat of a binary file (actually it was
randseed.bin, one of pgp's files). This caused text displayed
on the virtual terminal to be unreadable. It appears that
upper case characters and numbers are unaffected, but lower case
letters have all been replaced with graphic characters (lines,
squares and other funny symbols). This only affects the one terminal
from which I did the cat, and the only way of curing the problem
seems to be to reboot.

I run Linux 1.2.13 (from Slackware 3.0) on a PC. I run it at 80x50 but
I remember the same thing happening when I used to run at 80x25. Does
anyone know why this happens, and is there any way of getting my
normal character set back without rebooting?

TIA
--
Andy Moreton
an...@amore.demon.co.uk

Matthew Galloway

unread,
Feb 13, 1997, 3:00:00 AM2/13/97
to

Andy Moreton (an...@amore.demon.co.uk) wrote:
: I recently did a cat of a binary file (actually it was

: TIA


Personally, I like "reset", but "stty sane" also works.
Both have bailed me out numerous times.

matt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Matthew R. Galloway | University of Nebraska |
| gall...@cse.unl.edu | Computer Science and Engineering |
| http://cse.unl.edu/~galloway | Assistant Systems Administrator |
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| Real programmers don't comment their code. |
| It was hard to write, it should be hard to understand. |
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| Documentation is the castor oil of programming. Managers |
| know it must be good because the programmers hate it so much. |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Matthew R. Galloway | University of Nebraska |
| gall...@cse.unl.edu | Computer Science and Engineering |
| http://cse.unl.edu/~galloway | Assistant Systems Administrator |

Stefan Huelbrock

unread,
Feb 13, 1997, 3:00:00 AM2/13/97
to

Andy Moreton (an...@amore.demon.co.uk) wrote:
> I recently did a cat of a binary file (actually it was
> randseed.bin, one of pgp's files). This caused text displayed
> on the virtual terminal to be unreadable. It appears that
Try to type ctrl-v and then esc-c followed by enter.
I don't know what this does but it cleans your console.

> upper case characters and numbers are unaffected, but lower case
> letters have all been replaced with graphic characters (lines,
> squares and other funny symbols). This only affects the one terminal
> from which I did the cat, and the only way of curing the problem
> seems to be to reboot.

> I run Linux 1.2.13 (from Slackware 3.0) on a PC. I run it at 80x50 but
> I remember the same thing happening when I used to run at 80x25. Does
> anyone know why this happens, and is there any way of getting my
> normal character set back without rebooting?

> TIA
> --
> Andy Moreton
> an...@amore.demon.co.uk

--
----------------------------------------
Bleib... bleib stehn oder ich schiess
auf mich. (Subway to Sally)
----------------------------------------
Stefan Huelbrock
Kurt-Schumacher-Str. 24a, 67663 Kaiserslautern, Phone 0621/27973

Richard W. Kong

unread,
Feb 13, 1997, 3:00:00 AM2/13/97
to

How about:

$ reset


Stefan Huelbrock (ste...@arielle.informatik.uni-kl.de) wrote:

Andy Moreton

unread,
Feb 13, 1997, 3:00:00 AM2/13/97
to

Andy Moreton (an...@amore.demon.co.uk) wrote:
> I recently did a cat of a binary file (actually it was
> randseed.bin, one of pgp's files). This caused text displayed
> on the virtual terminal to be unreadable.

Thanks very much to everyone who replied by email and in this group.
There seem to be several ways of solving the problem, but 'reset'
seems to be the easiest.

--
Andy Moreton
an...@amore.demon.co.uk

William McBrine

unread,
Feb 14, 1997, 3:00:00 AM2/14/97
to

If I may answer the other part of the question -- "Does anyone know why
this happens?"...

The VT100 terminal (emulated by Linux) is designed to work with a 7-bit
data path; hence a 7-bit character set, which just covers ASCII (letters,
numbers, punctuation, etc.). BUT, a VT100 also supports special box-
drawing characters and such. There's no room for these characters within 7
bits, so one character (?) was chosen as a control code to select the
*alternate* character set. When using the alternate set, characters that
would otherwise represent numbers and letters are interpreted as pieces of
lines, etc.

A binary may of course contain any random character. When the control code
for selecting the alternate character set is encountered in a binary and
'cat'ted to the screen, it changes the character set. But unlike with a
program that changes it on purpose, the code to change it back may never
show up. :-)

The above is my somewhat hazy understanding of the matter... corrections
welcome.

--
William McBrine | http://www.clark.net/pub/wmcbrine/html/
wmcb...@clark.net | Vote Ralph Nader for President in 2000!

Robert (Bob) B. Rager

unread,
Feb 14, 1997, 3:00:00 AM2/14/97
to

Stefan Huelbrock wrote:
>
> Andy Moreton (an...@amore.demon.co.uk) wrote:
> > I recently did a cat of a binary file (actually it was
> > randseed.bin, one of pgp's files). This caused text displayed
> > on the virtual terminal to be unreadable. It appears that
> Try to type ctrl-v and then esc-c followed by enter.
> I don't know what this does but it cleans your console.
>
> > upper case characters and numbers are unaffected, but lower case
> > letters have all been replaced with graphic characters (lines,
> > squares and other funny symbols). This only affects the one terminal
> > from which I did the cat, and the only way of curing the problem
> > seems to be to reboot.
------- stuff deleted to amke the m,ailer happy -----

What happens is that "cat" does not filter out unprintable chars. Some
of the chars following an "ESC" char have reset your code page.
<ctl>v <esc>C resets the code page. "stty -sane " usually clears things
but it may not restore the terminal completely to the logon state.

Try "stty -a >tty.at.logon" just after login. cat some binary, then
"stty -sane", and "stty -a >tty.reset".

Then do "diff tty.logon tty.reset " to see any differences.

In the future, become familiar with the "file" command and avoid
using "cat" on any file that is not some kind of "text". I use
the program called "strings" to examine binary files for information
in ASCII. "Cat" was never meant to be the general purpose file
viewer, its true purpose is to combine several ASCII files into one.

Is it not amazing how much one can learn about Linux/Unix by accident.
I became a terminfo expert after a system tester tried to browse a
binary file just to see what would happen. It was a terrific test
and our product is much more robust than ever before.

------ stuff deleted to make the mailer happy -----

Ivan Griffin

unread,
Feb 17, 1997, 3:00:00 AM2/17/97
to

In article <5dr14u$h...@amore.demon.co.uk>,

an...@amore.demon.co.uk (Andy Moreton) writes:
>I recently did a cat of a binary file (actually it was
>randseed.bin, one of pgp's files). This caused text displayed
>on the virtual terminal to be unreadable. It appears that
>upper case characters and numbers are unaffected, but lower case
>letters have all been replaced with graphic characters (lines,
>squares and other funny symbols). This only affects the one terminal
>from which I did the cat, and the only way of curing the problem
>seems to be to reboot.
>
>I run Linux 1.2.13 (from Slackware 3.0) on a PC. I run it at 80x50 but
>I remember the same thing happening when I used to run at 80x25. Does

>anyone know why this happens, and is there any way of getting my
>normal character set back without rebooting?

Since the first part has already been answered, I'll give an easy way
of fixing the second...

Type at the prompt (okay, so you can't see what you are typing... you'll
just have to trust your keyboard skills):

echo ^vESC-c

This means hold down the CTRL key and press V, and then press ESC and C.
This is the ANSI code to reset the terminal to its defaults. Usually works
for me if a binary file is displayed on the screen. Best regards,
Ivan.

0 new messages