1TTY(P)                     POSIX Programmer's Manual                    TTY(P)
2
3
4

NAME

6       tty - return user's terminal name
7

SYNOPSIS

9       tty
10

DESCRIPTION

12       The tty utility shall write to the standard output the name of the ter‐
13       minal that is open as standard input. The name that is  used  shall  be
14       equivalent  to the string that would be returned by the ttyname() func‐
15       tion defined in the System Interfaces volume of IEEE Std 1003.1-2001.
16

OPTIONS

18       The tty utility  shall  conform  to  the  Base  Definitions  volume  of
19       IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
20

OPERANDS

22       None.
23

STDIN

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

INPUT FILES

30       None.
31

ENVIRONMENT VARIABLES

33       The following environment variables shall affect the execution of tty:
34
35       LANG   Provide  a  default value for the internationalization variables
36              that are unset or null. (See  the  Base  Definitions  volume  of
37              IEEE Std 1003.1-2001,  Section  8.2,  Internationalization Vari‐
38              ables for the precedence of internationalization variables  used
39              to determine the values of locale categories.)
40
41       LC_ALL If  set  to a non-empty string value, override the values of all
42              the other internationalization variables.
43
44       LC_CTYPE
45              Determine the locale for  the  interpretation  of  sequences  of
46              bytes  of  text  data as characters (for example, single-byte as
47              opposed to multi-byte characters in arguments).
48
49       LC_MESSAGES
50              Determine the locale that should be used to  affect  the  format
51              and  contents  of  diagnostic messages written to standard error
52              and informative messages written to standard output.
53
54       NLSPATH
55              Determine the location of message catalogs for the processing of
56              LC_MESSAGES .
57
58

ASYNCHRONOUS EVENTS

60       Default.
61

STDOUT

63       If  standard  input is a terminal device, a pathname of the terminal as
64       specified by the ttyname() function defined in  the  System  Interfaces
65       volume  of  IEEE Std 1003.1-2001 shall be written in the following for‐
66       mat:
67
68
69              "%s\n", <terminal name>
70
71       Otherwise, a message shall be written indicating that standard input is
72       not connected to a terminal. In the POSIX locale, the tty utility shall
73       use the format:
74
75
76              "not a tty\n"
77

STDERR

79       The standard error shall be used only for diagnostic messages.
80

OUTPUT FILES

82       None.
83

EXTENDED DESCRIPTION

85       None.
86

EXIT STATUS

88       The following exit values shall be returned:
89
90        0     Standard input is a terminal.
91
92        1     Standard input is not a terminal.
93
94       >1     An error occurred.
95
96

CONSEQUENCES OF ERRORS

98       Default.
99
100       The following sections are informative.
101

APPLICATION USAGE

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

EXAMPLES

110       None.
111

RATIONALE

113       None.
114

FUTURE DIRECTIONS

116       None.
117

SEE ALSO

119       The System Interfaces volume of  IEEE Std 1003.1-2001,  isatty(),  tty‐
120       name()
121
123       Portions  of  this text are reprinted and reproduced in electronic form
124       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
125       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
126       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
127       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
128       event of any discrepancy between this version and the original IEEE and
129       The  Open Group Standard, the original IEEE and The Open Group Standard
130       is the referee document. The original Standard can be  obtained  online
131       at http://www.opengroup.org/unix/online.html .
132
133
134
135IEEE/The Open Group                  2003                               TTY(P)
Impressum