Updated 2015-02-11 20:13:25 by dkf

This Unix-ish command is used to communicate information from a script level program to a terminal device. It allows one to read and modify the various device attributes.

Tcl developers often make use of it on Linux or other Unix systems when they want to collect data from user input without requiring the user to press Return first.

It's also useful for prompting for passwords:
proc getpassword {{prompt "Password: "}} {
    puts -nonewline $prompt
    flush stdout
    # disable echoing
    exec stty -echo
    catch { gets stdin } password options
    exec stty echo
    return -options $options $password
}

Gotcha! On some versions of Solaris (at least) you need to pass the descriptor that you want to modify on stdin to the subprocess. On Linux, you don't need to: it defaults to the terminal that is the controlling TTY. Because of this difference, you are recommended to invoke stty like this:
exec stty {*}$whateverArguments <@stdin
# Alternatively...
exec stty {*}$whateverArguments </dev/tty

The Expect extension includes an stty command that takes much the same sort of parameters as the unix utility command.

See also edit