tty(1) tty(1)
NAME
tty - output path name of current terminal
SYNOPSIS
tty [-l] [-s]
DESCRIPTION
tty outputs the path name of the terminal with which the process is
linked. The exit status indicates whether or not standard input is a
terminal.
If the process is linked with a virtual terminal, tty returns the name
of the virtual terminal, not the real terminal.
The specified path name corresponds to that of the ttyname(3C) func-
tion. (The output format is "%s\n", <terminalname>, provided the pro-
cess is linked with a terminal and the -s option was not specified.)
OPTIONS
-l If the current terminal is on a synchronous line, the number of
the line is output.
-s Inhibits output of the terminal path name, returning the exit
status only.
Note: You should use test -t 0 to check whether you can read from
the standard input.
-s not specified: tty reports an error if standard input is not a
terminal.
EXIT STATUS
0 Standard input is a terminal.
1 Standard input is not a terminal.
>1 An invalid option was specified or an error occurred.
ERROR MESSAGES
not on an active synchronous line
The -l option was specified and the standard input is not a terminal
on an active synchronous line.
not a tty
The standard input is not a terminal and the -s option was not speci-
fied.
Page 1 Reliant UNIX 5.44 Printed 11/98
tty(1) tty(1)
LOCALE
The LCMESSAGES environment variable governs the language in which
message texts are displayed. If LCMESSAGES is undefined or is defined
as the null string, it defaults to the value of LANG. If LANG is like-
wise undefined or null, the system acts as if it were not internation-
alized.
The LCALL environment variable governs the entire locale. LCALL
takes precedence over all the other environment variables which affect
internationalization.
EXAMPLES
Example 1
Output the name of the current terminal:
$ tty
/dev/tty03
Example 2
The following script is to send output to the screen even if standard
output is redirected to a file:
.
.
echo 'Output to the terminal' > `tty`
.
.
Example 3
The following script is to generate an error message if standard input
is not the terminal:
.
.
if tty -s
then
read input
.
.
else
echo 'Standard input is not a terminal' >&2
fi
.
.
SEE ALSO
ttyname(3C).
Page 2 Reliant UNIX 5.44 Printed 11/98