The strangest error ever in Unix

Go To StackoverFlow.com

0

Not even sure how to explain this but I connect to a remote computer and execute a command which outputs various stuff to stdout for about 10 minutes. (I am basically running some experiments on a tool). After some time during the execution, the English characters that are being output strangely change into characters like below and stay like that even after the execution is finished. Below is me typing echo "what the hell" to the command line followed by the resulting output. This does not happen unless I use ssh. What on earth is going on?

°┤⎽␋⎺┼02% ␊␌␤⎺ "┬␤▒├ ├␤␊ ␤␊┌┌" 
 ┬␤▒├ ├␤␊ ␤␊┌┌
°┤⎽␋⎺┼02% 
2012-04-04 01:08
by Cemre
Execute: reset in the command line when this happens and see if it fixes the problem - karlphillip 2012-04-04 01:09
Unfortunately it doesnt. - Cemre 2012-04-04 01:09


3

In general, it's not safe to output arbitrary text that might include binary data to your terminal. It could include terminal escapes and the like.

You can add this to the pipeline to remove everything but printable ascii characters:

somecommand | tr -cd '\11\12\15\40-\176'
2012-04-04 01:14
by A B


2

Your terminal doesn't just display text, among other things it responds to various escape sequences that affects the terminal settings, which can change the font, character set, size, and other things.

When you're outputting binary data, either deliberate, or as a consequence of some bugs (e.g. printing out an uninitialized array), some of that binary data happens to be the special codes that the terminal interprets.

2012-04-04 01:13
by nos
Yes, the output is mostly binary data since it's a low level tool so I think this is definitely the case. Is it possible to stop my terminal responding to this kind of output ? (in OS X - Cemre 2012-04-04 01:18


2

Another trick to try is echoCtrl-VCtrl-O. The ^O character shifts out of the alternate character set for VT100-style terminals.

If that doesn't work (and all the other answers don't work), close your terminal and reconnect.

2012-04-04 01:15
by Greg Hewgill
Ah this worked fine its back to normal again! I am using OS X, is it possible to change the style of my terminal somehow - Cemre 2012-04-04 01:17
No, Terminal is VT100-compatible, and I don't think there are any other options. Just avoid sending binary data directly to your terminal. I often pipe through less (|less) which reformats control characters to something more readable - Greg Hewgill 2012-04-04 01:18
Ads