NAME
tty - Returns pathname of terminal device
SYNOPSIS
tty [-s]
The tty command writes the full pathname of your terminal
device to standard output.
FLAGS
-s Suppresses reporting the pathname (Obsolescent).
DESCRIPTION
The tty -s command evaluates as TRUE if standard output is a
display and FALSE if it is not.
The /dev/tty special file always refers to your controlling
terminal, although it also may have another name like
/dev/console or /dev/tty2. To avoid writing undesirable
output to an output file (for example, to write a prompt in
a shell script to the screen, while writing the response to
the prompt to an output file) redirect standard output to
/dev/tty.
EXAMPLES
1. To display the full pathname of your terminal device,
enter:
tty
2. To test whether or not the standard input is a terminal
device, enter:
if test -t 0
then
echo "Output is a display"
else
echo "Output is not a display"
FILES
/dev/tty
Pseudodevice representing the user's controlling ter-
minal.
DIAGNOSTICS
not a tty Your standard input is not an interactive terminal
and you did not specify the -s flag.
EXIT VALUES
The exit value has the following possible meanings:
0 Standard input is a tty.
1 Standard input is not a tty.
2 Invalid flags specified or other error.
RELATED INFORMATION
Commands: stty(1).
Subroutines: isatty(3), ttyname(3).
Files: tty(7).
Acknowledgement and Disclaimer