The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

tty - return user's terminal name

 SYNOPSIS



tty

tty -s

 DESCRIPTION

The tty utility writes to the standard output the name of the terminal that is open as standard input. The name that is used is equivalent to the string that would be returned by the XSH specification ttyname() function.

 OPTIONS

The tty utility supports the XBD specification, Utility Syntax Guidelines  .

The following option is supported:

-s
Do not write the terminal name. Only the exit status will be affected by this option. The terminal status will be determined as if the XSH specification isatty() function were used.

 OPERANDS

None.

 STDIN

While no input is read from standard input, standard input will be examined to determine whether or not it is a terminal, and, if so, to determine the name of the terminal.

 INPUT FILES

None.

 ENVIRONMENT VARIABLES

The following environment variables affect the execution of tty:
LANG
Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.
LC_ALL
If set to a non-empty string value, override the values of all the other internationalisation variables.
LC_CTYPE
Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments).
LC_MESSAGES
Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error and informative messages written to standard output.
NLSPATH
Determine the location of message catalogues for the processing of LC_MESSAGES .

 ASYNCHRONOUS EVENTS

Default.

 STDOUT

If the -s option is specified, standard output will not be used. If the -s option is not specified and standard input is a terminal device, a pathname of the terminal as specified by the XSH specification ttyname() will be written in the following format:

"%s\n", <terminal name>

Otherwise, a message will be written indicating that standard input is not connected to a terminal. In the POSIX locale, the tty utility will use the format:


"not a tty\n"

 STDERR

Used only for diagnostic messages.

 OUTPUT FILES

None.

 EXTENDED DESCRIPTION

None.

 EXIT STATUS

The following exit values are returned:
0
Standard input is a terminal.
1
Standard input is not a terminal.
>1
An error occurred.

 CONSEQUENCES OF ERRORS

Default.

 APPLICATION USAGE

This utility checks the status of the file open as standard input against that of a system-defined set of files. It is possible that no match can be found, or that the match found need not be the same file as that which was opened for standard input (although they are the same device).

The -s option is useful only if the exit code is wanted. It does not rely on the ability to form a valid pathname. Portable applications should use test -t 0.

 EXAMPLES

None.

 FUTURE DIRECTIONS

None.

 SEE ALSO

The XSH specification description of isatty(), ttyname().

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]