[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Commands Reference, Volume 5

stty Command

Purpose

Sets, resets, and reports workstation operating parameters.

Syntax

stty [ -a ] [ -g ] [ Options ]

Description

The stty command sets certain I/O options for the device that is the current standard input. This command writes output to the device that is the current standard output.

This version of AIX uses the standard XPG4 interface to control the terminals, maintaining a compatibility with POSIX and BSD interfaces. The stty command supports both POSIX and BSD compliant options, but the usage of POSIX options is strongly recommended. A list of obsolete BSD options, with the corresponding POSIX options, is also provided.

When you redirect standard input from a tty device by entering

 stty -a </dev/ttyx

the stty command (POSIX) will hang while waiting for the open() of that tty until the RS-232 carrier detect signal has been asserted. Exceptions to this rule occur if the clocal or forcedcd (128-port only) option is set.

Flags

-a Writes the current state of all option settings to standard output.
-g Writes option settings to standard output in a form usable by another stty command.

Options

The stty command supports following categories of options:

Control Modes
clocal Assumes a line without modem control.
-clocal Assumes a line with modem control.
cread Enables the receiver.
-cread Disables the receiver.
cstopb Selects 2 stop bits per character.
-cstopb Selects 1 stop bit per character.
cs5, cs6, cs7, cs8 Selects character size.
hup, hupcl Hangs up dial-up connection on the last close.
-hup, -hupcl Does not hang up dial-up connection on the last close.
parenb Enables parity generation and detection.
-parenb Disables parity generation and detection.
parodd Selects odd parity.
-parodd Selects even parity.
0 Hangs up phone line immediately.
speed Sets the workstation input and output speeds to the specified speed number of bits per second. All speeds are not supported by all hardware interfaces. Possible values for speed are: 50, 75, 110, 134, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 19.2, 38400, 38.4, exta, and extb.
Note: exta, 19200, and 19.2 are synonyms; extb, 38400, and 38.4 are synonyms.
ispeed speed Sets the workstation input speed to the specified speed number of bits per second. All speeds are not supported by all hardware interfaces, and all hardware interfaces do not support this option. Possible values for speed are the same as for the speed option.
ospeed speed Sets the workstation output speed to the specified speed number of bits per second. All speeds are not supported by all hardware interfaces, and all hardware interfaces do not support this option. Possible values for speed are the same as for the speed option.
Input Modes
brkint Signals INTR on break.
-brkint Does not signal INTR on break.
icrnl Maps CR to NL on input.
-icrnl Does not map CR to NL on input.
ignbrk Ignores BREAK on input.
-ignbrk Does not ignore BREAK on input.
igncr Ignores CR on input.
-igncr Does not ignore CR on input.
ignpar Ignores parity errors.
-ignpar Does not ignore parity errors.
inlcr Maps NL to CR on input.
-inlcr Does not map NL to CR on input.
inpck Enables parity checking.
-inpck Disables parity checking.
istrip Strips input characters to 7 bits.
-istrip Does not strip input characters to 7 bits.
iuclc Maps uppercase alphabetic characters to lowercase.
-iuclc Does not map uppercase alphabetic characters to lowercase.
ixany Allows any character to restart output.
-ixany Allows only the START (the Ctrl-Q key sequence) to restart output.
ixoff Sends START/STOP characters when the input queue is nearly empty/full.
-ixoff Does not send START/STOP characters.
ixon Enables START/STOP output control. Once START/STOP output control has been enabled, you can pause output to the workstation by pressing the Ctrl-S key sequence and resume output by pressing the Ctrl-Q key sequence.
-ixon Disables START/STOP output control.
imaxbel Echoes the BEL character and discards the last input character if input overflows.
-imaxbel Discards all input if input overflows.
parmrk Marks parity errors.
-parmrk Does not mark parity errors.
Output Modes
bs0, bs1 Selects style of delay for backspaces (bs0 siginifes no delay).
cr0, cr1, cr2, cr3 Selects style of delay for CR characters (cr0 siginifes no delay).
ff0, ff1 Selects style of delay for form feeds (ff0 siginifes no delay).
nl0, nl1 Selects style of delay for NL characters (nl0 siginifes no delay).
ofill Uses fill characters for delays.
-ofill Uses timing for delays.
ocrnl Maps CR characters to NL characters.
-ocrnl Does not map CR characters to NL characters.
olcuc Maps lowercase alphabetic characters to uppercase on output.
-olcuc Does not map lowercase alphabetic characters to uppercase on output.
onlcr Maps NL characters to CR-NL characters.
-onlcr Does not map NL characters to CR-NL characters.
onlret On the terminal, NL performs the CR function.
-onlret On the terminal, NL does not perform the CR function.
onocr Does not output CR characters at column zero.
-onocr Outputs CR characters at column zero.
opost Processes output.
-opost Does not process output; that is, ignores all other output options.
ofdel Uses DEL characters for fill characters.
-ofdel Uses NUL characters for fill characters.
tab0, tab1, tab2 Selects style of delay for horizontal tabs (tab0 siginifes no delay).
tab3 Expands tab character to variable number of spaces.
vt0, vt1 Selects style of delay for vertical tabs (vt0 siginifes no delay).
Local Modes
echo Echoes every character typed.
-echo Does not echo characters.
echoctl Echoes control characters as ^X (Ctrl-X), where X is the character given by adding 100 octal to the code of the control character.
-echoctl Does not echo control characters as ^X (Ctrl-X).
echoe Echoes the ERASE character as the "backspace space backspace" string.
Note: This mode does not keep track of column position, so you can get unexpected results when erasing such things as tabs and escape sequences.
-echoe Does not echo the ERASE character, just backspace.
echok Echoes a NL character after a KILL character.
-echok Does not echo a NL character after a KILL character.
echoke Echoes the KILL character by erasing each character on the output line.
-echoke Just echoes the KILL character.
echonl Echoes the NL character.
-echonl Does not echo the NL character.
echoprt Echoes erased characters backwards with / (slash) and \ (backslash).
-echoprt Does not echo erased characters backwards with / (slash) and \ (backslash).
icanon Enables canonical input (canonical input allows input-line editing with the ERASE and KILL characters). See the discussion about canonical mode input in Line Discipline Module (ldterm) AIX Version 4.3 Communications Programming Concepts.
-icanon Disables canonical input.
iexten Specifies that implementation-defined functions shall be recognized from the input data. Recognition of the following control characters requires iexten to be set: eol2, dsusp, reprint, discard, werase, lnext. The functions associated with these modes also require iexten to be set: imaxbel, echoke, echoprt, and echoctl.
-iexten Specifies that implementation-defined functions shall not be recognized from the input data.
isig Enables the checking of characters against the special control characters INTR, SUSP and QUIT special control characters.
-isig Disables the checking of characters against the special control characters INTR, SUSP and QUIT special control characters.
noflsh Does not clear buffers after INTR, SUSP, or QUIT control characters.
-noflsh Clears buffers after INTR, SUSP, or QUIT control characters.
pending Causes any input that is pending after a switch from raw to canonical mode to be re-input the next time a read operation becomes pending or the next time input arrives. Pending is an internal state bit.
-pending No text is pending.
tostop Signals SIGTOU for background output.
-tostop Does not signal SIGTOU for background output.
xcase Echoes uppercase characters on input, and displays uppercase characters on output with a preceding \ (backslash).
-xcase Does not echo uppercase characters on input.

Hardware Flow Control Modes

These options are extensions to the XPG4 standard.

cdxon Enables CD hardware flow control mode on output.
-cdxon Disables CD hardware flow control mode on output.
ctsxon Enables CTS hardware flow control mode on output.
-ctsxon Disables CTS hardware flow control mode on output.
dtrxoff Enables DTR hardware flow control mode on input.
-dtrxoff Disables DTR hardware flow control mode on input.
rtsxoff Enables RTS hardware flow control mode on input.
-rtsxoff Disables RTS hardware flow control mode on input.

Control Assignments

To assign a control character to a character string, enter:

stty Control String

where the Control parameter may be the INTR, QUIT, ERASE, KILL, EOF, EOL, EOL2, START, STOP, SUSP, DSUSP, REPRINT, DISCARD, WERASE, LNEXT, MIN, or TIME character. (Use the MIN and TIME characters with the -icanon option.)

Note: The values for MIN and TIME are interpreted as integer values, not as character values.

The String parameter may be any single character such as c. An example of this control assignment is:

stty STOP c

Another way of assigning control characters is to enter a character sequence composed of a \^ (backslash, circumflex) followed by a single character. If the single character after the ^ (circumflex) is one of the characters listed in the ^c (circumflex c) column of the following table, the corresponding control character value will be set. For example, to assign the DEL control character by using the ? (question mark) character, enter the string \^? (backslash, circumflex, question mark), as in:

stty ERASE \^?

Circumflex Control Characters in stty
^c Value ^c Value ^c Value
a, A <SOH> l, L <FF> w, W <ETB>
b, B <STX> m, M <CR> x, X <CAN>
c, C <ETX> n, N <SO> y, Y <EM>
d, D <EOT> o, O <SI> z, Z <SUB>
e, E <ENQ> p, P <DLE> [ <ESC>
f, F <ACK> q, Q <DC1> \ <FS>
g, G <BEL> r, R <DC2> ] <GS>
h, H <BS> s, S <DC3> ^ <RS>
i, I <HT> t, T <DC4> _ <US>
j, J <LF> u, U <NAK> ? <DEL>
k, K <VT> v, V <SYN> @ <NUL>
Combination Modes
cooked See the -raw option.
ek Sets ERASE and KILL characters to the Ctrl-H and Ctrl-U key sequences, respectively.
evenp Enables parenb and cs7.
-evenp Disables parenb and sets cs8.
lcase, LCASE Sets xcase, iuclc, and olcuc. Used for workstations with uppercase characters only.
-lcase, -LCASE Sets -xcase, -iuclc, and -olcuc.
nl Sets -icrnl and -onlcr.
-nl Sets icrnl, onlcr, -inlcr, -igncr, -ocrnl, and -onlret.
oddp Enables parenb, cs7, and parodd.
-oddp Disables parenb and sets cs8.
parity See the evenp option.
-parity See the -evenp option.
sane Resets parameters to reasonable values.
raw Allows raw mode input (no input processing, such as erase, kill, or interrupt); parity bit passed back.
-raw Allows canonical input mode.
tabs Preserves tabs.
-tabs, tab3 Replaces tabs with spaces when printing.
Window Size
cols n, columns n The terminal (window) size is recorded as having n columns.
rows n The terminal (window) size is recorded as having n rows.
size Prints the terminal (window) sizes to standard output (first rows and then columns).

Obsolete Options

The following BSD options are supported by the stty command. For each of them, the recommended POSIX option is given.

all Use the stty -a command to display all current settings.
crt Use the sane option to reset parameters to reasonable values.
crtbs Use the -echoe option.
crterase Use the echoe option.
-crterase Use the -echoe option.
crtkill Use the echoke option.
-crtkill Use the echok and -echoke options.
ctlecho Use the echoctl option.
-ctlecho Use the -echoctl option.
decctlq Use the -ixany option.
-decctlq Use the ixany option.
even Use the evenp option.
-even Use the -evenp option.
everything Use the stty -a command to display all current settings.
litout Use the -opost option.
-litout Use the opost option.
odd Use the oddp option.
-odd Use the -oddp option.
pass8 Use the -istrip option.
-pass8 Use the istrip option.
prterase Use the echoprt option.
speed Use the stty command to display current settings.
tandem Use the ixoff option.
-tandem Use the -ixoff option.

Examples

  1. To display a short listing of your workstation configuration, enter:
    stty
    This lists settings that differ from the defaults.
  2. To display a full listing of your workstation configuration, enter:
    stty -a
  3. To enable a key sequence that stops listings from scrolling off the screen, enter:
    stty ixon ixany
    This sets ixon mode, which lets you stop runaway listing by pressing the Ctrl-S key sequence. The ixany flag allows you to resume the listing by pressing any key. The normal workstation configuration includes the ixon and ixany flags, which allows you to stop a listing with the Ctrl-S key sequence that only the Ctrl-Q key sequence will restart.
  4. To reset the configuration after it has been messed up, enter:
    Ctrl-J stty sane Ctrl-J
    Press the Ctrl-J key sequence before and after the command instead of the Enter key. The system usually recognizes the Ctrl-J key sequence when the parameters that control Enter key processing are messed up.

    Sometimes the information displayed on the screen may look strange, or the system will not respond when you press the Enter key. This can happen when you use the stty command with parameters that are incompatible or that do things you don't understand. It can also happen when a screen-oriented application ends abnormally and does not have a chance to reset the workstation configuration.

    Entering the stty sane command sets a reasonable configuration, but it may differ slightly from your normal configuration.

  5. To save and restore the terminal's configuration:
    OLDCONFIG=`stty -g`          # save configuration
    stty -echo                   # do not display password
    echo "Enter password: \c"
    read PASSWD                  # get the password
    stty $OLDCONFIG              # restore configuration
    This command saves the workstation's configuration, turns off echoing, reads a password, and restores the original configuration.

    Entering the stty -echo command turns off echoing, which means that the password does not appear on the screen when you type it at the keyboard. This action has nothing to do with the echo command, which displays a message on the screen.

File

/usr/bin/stty Contains the stty command.

Related Information

The terminfo file, tty special file termios.h header file.

National Language Support Overview for Programming and TTY Subsystem Overview in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.

ldterm Line Discipline in AIX General Programming Concepts: Writing and Debugging Programs.


[ Previous | Next | Contents | Glossary | Home | Search ]