[Previous] [Contents] [Next]

tty

Return user's terminal name (POSIX)

Syntax:

tty [-s]

Options:

-s
Be silent; don't output the terminal name. This option is useful if you're concerned only with tty's exit status.

Description:

The tty utility writes to the standard output the name of the terminal that is open as standard input. If standard input isn't a terminal (e.g. it is a file such as /dev/null), the string not a tty is output instead.


Note: The -s option is deprecated by POSIX; the effect of this option can be achieved, simply and portably, by redirecting output to /dev/null or by using the Shell builtin, test -c.

Examples:

The following command will output //14/dev/con1 if run on node 14, console 1.

    tty

The following command will output not a tty since /dev/null causes the isatty() function to return 0.

    tty </dev/null

Exit status:

0
Successful completion.
>0
An error occurred.

[Previous] [Contents] [Next]