This ends up in me screwing up my terminal unto a unresponsive state with
oodles of junk characters on my screen.
Is there a way to "idiot proof" my shell so that "something" comes in the
way of me doing this? Maybe a wrapper around cat etc. Or a way to get out
of this once my shell starts to hang on those strange characters?
--
Rahul
When you get the crazy characters on your terminal screen, depending on
the environment, you can either type "reset" or you can cat a bunch of
text files in something like /etc (just as an example) and it'll reset
the screen's characters for you (weird way of doing it, huh?). I'd
also recommend using less or more for viewing text files, as you
unlikely want to actually use cat in most situations.
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
I don't think you can wrap cat, because it is used internally by many
tools, and it does handle binary files.
You could get used to typing cat -v , or you could create another
command that uses this, you would then have to get used to typing the
new command of course, which won't be easy, if cat still works, because
you will type cat out of habit.
I have the same problem sometimes, because some of the files currently
in /etc are binary and sometimes this catches me out.
> Or a way to get out
> of this once my shell starts to hang on those strange characters?
You can sometimes reset the terminal (I think using Ctrl-O), but often I
end up killing the session from another terminal.
I have noticed that when I used to use Red Hat 6, and Debian Sarge, if I
typed a command and strange characters were appearing, when I pressed
enter, the command was rejected as nonsense.
However, I notice with Debian Etch and Debian Lenny, that if I type a
command and strange characters were appearing, when I pressed enter the
command was properly received.
Don't logout on a screwed terminal, because the login prompt is screwed.
Note that executable binary files do not need read permission, you could
make the execute only, and you could knock read permissions off files
that you do not need access too.
Mark.
--
Mark Hobley
Linux User: #370818 http://markhobley.yi.org/
A way I get out of it is to more the file again... Whatever arcane ansi
control codes caused the switch to gibberish often have an antidolt in the
same binary. :)
--
| spi...@freenet.co.uk | |
| Andrew Halliwell BSc | "ARSE! GERLS!! DRINK! DRINK! DRINK!!!" |
| in | "THAT WOULD BE AN ECUMENICAL MATTER!...FECK!!!! |
| Computer Science | - Father Jack in "Father Ted" |
> Bill Marcum <marcu...@bellsouth.net> wrote:
>> On 2009-03-09, Rahul <nos...@nospam.invalid> wrote:
>>>
>>>
>>> Often, in a bout of great stupidity, I end up catting files I
>>> shouldn't. eg. executibles, files with encoded or encrypted data
>>> etc. I assume this is generically binary / non-text data.
>>>
>>> This ends up in me screwing up my terminal unto a unresponsive state
>>> with oodles of junk characters on my screen.
>>>
>>> Is there a way to "idiot proof" my shell so that "something" comes
>>> in the way of me doing this? Maybe a wrapper around cat etc. Or a
>>> way to get out of this once my shell starts to hang on those strange
>>> characters?
>>>
>> Often a way to get out of a junk screen is to type the command
>> "reset". Or you can switch to another window if you're using X, or
>> another virtual terminal if you use the console or screen. You could
>> get into the habit of using something other than cat to examine
>> unknown files, for example less or file.
>>
> Sometimes reset doesn't work.
>
> A way I get out of it is to more the file again... Whatever arcane
> ansi control codes caused the switch to gibberish often have an
> antidolt in the same binary. :)
>
Reset will depend on the environment, but you're right, often the
character sequence you hit when cat'ing a binary that scrambles the
characters on your screen, can be reset by cat'ing other files (such as
doing a cat /etc/* and breaking when you see normal characters again,
as there are files there that often contain a sequence that will reset
the characters, too, instead of trying to cat the same binary). In all
"exit" and logging back in also works. :-)
You might alias "cat" to "cat -v".
When the terminal gets really badly messed up
try typing:
stty sane
followed by "control-j".
If you've already typed something, hit
control-j first.
> This ends up in me screwing up my terminal unto a unresponsive state with
> oodles of junk characters on my screen.
When that happens, press "ctrl & c", to terminate the command, and
type in "reset", and press enter.
Regards, Dave Hodgins
--
Change nomail.afraid.org to ody.ca to reply by email.
(nomail.afraid.org has been set up specifically for
use in usenet. Feel free to use it yourself.)
cat() { [ -t 1 ] && set -- -v ${1+"$@"} ; /bin/cat ${1+"$@"} ; }
> Or a way to get out
> of this once my shell starts to hang on those strange characters?
^C
tput reset
stty sane
> When that happens, press "ctrl & c", to terminate the command, and
> type in "reset", and press enter.
>
>
WOW! So many solutions! I hadn't expected that. Thanks: Andrew, Bill,
Tim, Mark Dan, David and Dave!
I was super-skeptical of the "cat /etc/*" but that surprised me by
actually working. The game of hitting Ctrl+C exactly when I see "regular
text" during a rapid scroll reminds me of an arcade game! :)
Aliasing cat to "cat -v" also solves my problems.
Thanks guys!
Just to document my adventures:
> Often a way to get out of a junk screen is to type the command "reset".
Did not work.
> You can sometimes reset the terminal (I think using Ctrl-O), but often
Did not work.
> stty sane
> followed by "control-j".
No luck either.
> ^C>
tput res> et
stty sane
Again, did not work.
--
Rahul
> Is there a way to "idiot proof" my shell so that "something" comes in the
> way of me doing this? Maybe a wrapper around cat etc. Or a way to get out
> of this once my shell starts to hang on those strange characters?
This is what 'd do:
Type Control-S to stop the characters from going to the screen.
Then type
Control-C (to kill the process)
reset(Control-J)
clear
You need the control-J after reset because sometimes the terminal is
in raw mode, and (cr) won't work.
I guess you can also set the terminal speed to be slower, so that a
zillion characters won't go by when you goof.
stty 19200
> "David W. Hodgins" <dwho...@nomail.afraid.org> wrote in
> news:op.uqjfm7r...@hodgins.homeip.net:
>
>> When that happens, press "ctrl & c", to terminate the command, and
>> type in "reset", and press enter.
...
> Did not work.
>
>> stty sane
>> followed by "control-j".
>
> No luck either.
Can't explain that, that has worked for me many times.
I've seen the enter key (return) go bad so I'm not surprised some
of the other solutions didn't work but C-j stty sane C-j
has always worked for me.