TTY(1) COMMAND REFERENCE TTY(1)
NAME
tty - get terminal name
SYNOPSIS
tty [ -s ]
DESCRIPTION
Tty prints the pathname of the user's terminal (found by
checking the standard input) unless the -s (silent) option
is given.
OPTIONS
-s Silent. Suppresses output.
EXAMPLES
The following example shows how tty can be used in a shell
script to see if the shell script is being run with standard
input as a terminal:
#!/bin/sh
tty -s
if test $? -eq 1
then
echo "Input is not from a terminal."
else
echo "Input is from a terminal."
fi
RETURN VALUE
[0] Standard input is a terminal.
[1] Standard input is not a terminal.
CAVEATS
When using tty in a shell script, it is important to note
that if the standard input is being redirected, as in a pipe
(|), the terminal name cannot be determined.
SEE ALSO
test(1sh), ttyname(3c).
Printed 10/17/86 1
%%index%%
na:72,59;
sy:131,104;
de:235,250;
op:485,99;
ex:584,443;
rv:1027,185;
ca:1212,248;
se:1460,121;
%%index%%000000000129