Writes to standard output the full path name of your terminal.
/usr/bin/tty [ -s ]
The tty command writes the name of your terminal to standard output.
If your standard input is not a terminal and you do not specify the -s flag, you get the message Standard input is not a tty .
The following environment variables affect the execution of the tty command:
|LANG||Determines the locale to use for the locale categories when neither the LC_ALL variable nor the corresponding environment variable beginning with LC_ specifies a locale.|
|LC_ALL||Determines the locale to be used. This variable overrides any values for locale categories that are specified by any other environment variable beginning with LC_ or by the LANG variable.|
|LC_CTYPE||Determines the locale for the interpretation of sequences of bytes of text data as characters. For example, this variable may specify multi-byte characters instead of single-byte characters.|
|LC_MESSAGES||Determines the language for messages.|
|-s||Suppresses reporting the path name.|
This command returns the following exit values:
|0||Standard input is a terminal.|
|1||Standard input is not a terminal.|
|>1||An error occurred.|
if tty -s then echo 'Enter the text to print:' >/dev/tty fi qprt
If the standard input is a terminal, this displays the message "Enter the text to print:" as a prompt and prints the text that the user types. If the standard input is not a terminal, this displays nothing; it merely prints the text read from the standard input.
The echo . . . >/dev/tty displays the prompt on the screen even if you redirect the standard output of the shell procedure. This way the prompt is never written into an output file. The special file /dev/tty always refers to your terminal, although it also has another name such as /dev/console or /dev/tty2.
|/usr/bin/tty||Contains the tty command.|
|/dev/tty||Specifies the tty pseudo device.|
The National Language Support Overview for Programming in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs discusses the LC_ variables.