Help on control keys

Barry Margolin barmar at think.COM
Sat Dec 31 07:22:09 AEST 1988


In article <893 at husc6.harvard.edu> yylu at walsh.UUCP (Ya Yan Lu) writes:
>  Is it possible to put some
>control characters in an ascii file, so that whenever I read that file 
>by cat or more, it actually runs a program? 

In general, the answer is "No".  Cat and more mostly just send the
characters to the terminal (I think "more" will also recognize certain
sequences as indicating underlining and inverse video, and translate
them to the appropriate sequence for the terminal).

Some terminals have mechanisms whereby a "answerback" strings may be
programmed using control sequences, and then another control sequence
causes it to send the answerback as if the user had typed it.  For
such terminals, the file could contain the sequence to program an
answerback and then request it to be sent.  If the answerback is set
to be a command line, this mechanism could be used to cause a program
to be run after the file is displayed.

					     When cat or more are used, the 
>control keys in a file usually have some effect, but I am not so clear 
>what they really are.

Are you referring to the file that displays a train going around a
christmas tree when you cat it?  In that case, the file simply
contains the control sequences that cause characters to be displayed
and erased at the appropriate places on a VT100-compatible terminal.
The control characters in the file aren't causing a special program to
run, they're just being sent to the terminal, and you're seeing the
results of those control sequences on the terminal's display.


Barry Margolin
Thinking Machines Corp.

barmar at think.com
{uunet,harvard}!think!barmar



More information about the Comp.unix.questions mailing list