tty
PURPOSE
Writes to standard output the full path name of your work
station.
SYNOPSIS
tty [ -s ]
DESCRIPTION
The tty command writes the name of your work station to
standard output.
FLAG
-s Suppresses reporting the path name. The exit value
has the following possible meanings:
0 Standard input is a work station.
1 Standard input is not a work station.
2 Invalid flags specified.
If your standard input is not a work station and you do
not specify the -s flag, you get the message "not a tty".
EXAMPLES
1. To display full path name of your work station:
tty
2. To test whether or not the standard input is a work
station:
if tty -s
then
echo 'Enter the text to print:' >/dev/tty
fi
print
If the standard input is a work station, this dis-
plays the message "Enter the text to print:" as a
prompt and prints the text that the user types. If
the standard input is not a work station, this dis-
plays nothing. It merely prints the text read from
the standard input.
The "echo . . . >/dev/tty" displays the prompt on the
screen even if you redirect the standard output of
the shell procedure. This way the prompt is never
written into an output file. The special file
/dev/tty always refers your work station, although it
also has another name like /dev/console or /dev/tty2.