CTTY is a little-known and little-used command supported by MS-DOS and many versions of Windows, but not those based on the NT kernel.

CTTY stands for Change TTY. It allows the selection of an alternative device to be used for all future console I/O operations by the command interpreter. In other words, instead of reading commands from the keyboard and displaying output to the screen, commands will be read from the indicated device and output sent to same.

Using CTTY is somewhat like redirecting the input and output of all subsequent commands. However, CTTY is a dangerous command, which is probably why it was removed in recent operating systems. It is dangerous because, unlike redirection, the keyboard break is ignored; that is, control-C no longer operates. The only way to revert back to normal console operations after issuing a CTTY is for the new console to execute CTTY CON. Another difference between using CTTY and conventional redirection is that CTTY will redirect stderr as well as stdout.

There are two practical uses of CTTY that I can think of. One allows you to control a system over a serial line, or even a modem. By issuing CTTY COM1 (for example), the first serial port will be treated as the console by the current command interpreter. Another system can then execute commands on the first by sending them to the appropriate serial port on that system.

The other practical use of CTTY is to universally hide output and prevent break within a batch file. For example, by placing a CTTY NUL early in an AUTOEXEC.BAT file, the user will be unable to abort batch processing until a corresponding CTTY CON is executed. However, this technique masks errors as well, and the user will not be notified if there is a problem within AUTOEXEC. If there is an error in the batch file that prevents the whole file from being processed, then the CTTY CON may never be executed, rendering the system unusable.

Log in or register to write something here or to contact authors.