The strangest error ever in Unix

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% 

Answers


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'

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.


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.


Need Your Help

.NET Development on a Mac Tips

.net macos vmware virtualization

I have just got a MacBook Pro and have been using it (+Fusion) to develop on for about a month now. The purpose of this question is similar to Hidden Features of C#; to become a how-to of tips and...

Android API for detecting new media from inbuilt camera & mic

java android api multimedia

Is there any elegant way in the Android API for detecting new media when it is written to the device? I’m mainly interested in photos taken by the camera, video taken by the camera and audio recorded