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

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       tty — return user's terminal name
14

SYNOPSIS

16       tty
17

DESCRIPTION

19       The tty utility shall write to the standard output the name of the ter‐
20       minal  that  is  open as standard input. The name that is used shall be
21       equivalent to the string that would be returned by the ttyname()  func‐
22       tion defined in the System Interfaces volume of POSIX.1‐2008.
23

OPTIONS

25       The  tty  utility  shall  conform  to  the  Base  Definitions volume of
26       POSIX.1‐2008, Section 12.2, Utility Syntax Guidelines.
27

OPERANDS

29       None.
30

STDIN

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

INPUT FILES

37       None.
38

ENVIRONMENT VARIABLES

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

ASYNCHRONOUS EVENTS

64       Default.
65

STDOUT

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

STDERR

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

OUTPUT FILES

83       None.
84

EXTENDED DESCRIPTION

86       None.
87

EXIT STATUS

89       The following exit values shall be returned:
90
91        0    Standard input is a terminal.
92
93        1    Standard input is not a terminal.
94
95       >1    An error occurred.
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 Base Definitions volume of  POSIX.1‐2008,  Chapter  8,  Environment
120       Variables, Section 12.2, Utility Syntax Guidelines
121
122       The System Interfaces volume of POSIX.1‐2008, isatty(), ttyname()
123
125       Portions  of  this text are reprinted and reproduced in electronic form
126       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
127       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
128       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
129       cal  and  Electronics  Engineers,  Inc  and  The  Open Group.  (This is
130       POSIX.1-2008 with the 2013 Technical Corrigendum  1  applied.)  In  the
131       event of any discrepancy between this version and the original IEEE and
132       The Open Group Standard, the original IEEE and The Open Group  Standard
133       is  the  referee document. The original Standard can be obtained online
134       at http://www.unix.org/online.html .
135
136       Any typographical or formatting errors that appear  in  this  page  are
137       most likely to have been introduced during the conversion of the source
138       files to man page format. To report such errors,  see  https://www.ker
139       nel.org/doc/man-pages/reporting_bugs.html .
140
141
142
143IEEE/The Open Group                  2013                              TTY(1P)
Impressum