Online Book Reader

Home Category

UNIX System Administration Handbook - Evi Nemeth [73]

By Root 2638 0
kill, and erase characters to , , and (backspace), respectively.

You can use stty to examine the current modes of the terminal driver as well as to set them. stty with no arguments produces output like this:

% stty

speed 9600 baud; -parity hupcl

rows = 24; columns = 80

erase = ^h; swtch = ;

brkint -inpck -istrip icrnl -ixany imaxbel onlcr

echo echoe echok echoctl echoke iexten

For a more verbose status report, run stty everything, stty -a, or stty all, depending on your system. The output in this case is something like:

% stty -a

speed 9600 baud;

rows = 24; columns = 80; ypixels = 364; xpixels = 739;

eucw 1:0:0:0, scrw 1:0:0:0

intr = ^c; quit = ^|; erase = ^h; kill = ^u; eof = ^d; eol = ;

eol2 = ; swtch = ; start = ^q; stop = ^s; susp = ^z;

dsusp = ^y; rprnt = ^r; flush = ^o; werase = ^w; lnext = ^v;

-parenb -parodd cs8 -cstopb hupcl cread -clocal -loblk -crtscts

-parext -ignbrk brkint ignpar -parmrk -inpck -istrip -inlcr

-igncr icrnl -iuclc ixon -ixany -ixoff imaxbel isig icanon -xcase

echo echoe echok -echonl -noflsh -tostop echoctl -echoprt echoke

-defecho -flusho -pendin iexten opost -olcuc onlcr -ocrnl -onocr

-onlret -ofill -ofdel

The format of the output is similar but lists more information. The meaning of the output should be intuitively obvious (if you’ve written a terminal driver recently).

stty operates on the file descriptor of its standard input or standard output (depending on your system), so it is possible to set and query the modes of a terminal other than the current one by using the shell redirection characters “>” and “<”. On most systems, you must be the superuser to change the modes on someone else’s terminal.

7.11 TSET: SET OPTIONS AUTOMATICALLY


tset initializes the terminal driver to a mode appropriate for a given terminal type. The type can be specified on the command line; if it is left out, tset uses the value of the TERM environment variable.

tset supports a syntax for mapping certain values of the TERM environment variable into other values. This feature is useful if you often log in through a modem or data switch and would like to have the terminal driver configured correctly for the terminal you are really using on the other end of the connection rather than something generic and unhelpful such as “dialup.”

7.12 HOW TO UNWEDGE A TERMINAL


Some programs (such as vi) make drastic changes to the state of the terminal driver while they are running. This meddling is normally invisible to the user, since the terminal state is carefully restored whenever the program exits or is suspended. However, it is possible for a program to crash or be killed without performing this housekeeping. When this happens, your terminal may behave very strangely: it might fail to handle newlines correctly, to echo characters that you type, or to execute commands properly.

Another common way to confuse a terminal is to accidentally run cat or more on a binary file. Most binaries contain a delicious mix of special characters that is guaranteed to send some of the less-robust terminals and emulators into outer space.

To fix this situation, you can use reset or stty sane. reset is actually just a link to tset on most systems, and it can accept most of tset’s arguments. However, it is usually run without arguments. Both reset and stty sane restore the correctitude of the terminal driver and send out an appropriate reset code from termcap or terminfo, if one is available.

In many cases where a reset is appropriate, the terminal has been left in a mode in which no processing is done on the characters you type. Most terminals generate carriage returns rather than newlines when the Return or Enter key is pressed; without input processing, this key generates characters instead of sending the current command off to be executed. To enter newlines directly, use or the line feed key (if there is one) instead of the Return key.

7.13 MODEMS


A modem converts the digital serial signal produced

Return Main Page Previous Page Next Page

®Online Book Reader