To receive messages you must be working on a character-mode terminal; in other words, you must be accessing the POSIX shell via rlogin.
In contrast, all users can send messages, including those working on block-mode terminals.
write is used to send messages to another user. write reads one line at a time from standard input and echoes the lines read as messages on the specified user’s terminal. When write is invoked, a message header initially appears on the recipient’s terminal indicating the name of the sender, the terminal, and the time at which the message is sent. This is followed by the actual messages.
Users may communicate interactively by sending messages to each other with write (see "Two-way conversations").
Before the call
Users who have denied other users permission to write to their terminals (with mesg -n) or who are working on block-mode terminals cannot be written to with write. A user with POSIX administrator privileges can write to any terminal. |
Syntax
write
recipient[ ttyname] text ... ... ... CTRL + D |
recipient Login name of a user logged in to a terminal. You can also send yourself messages. If a user is logged in to more than one terminal at the same time, the appropriate terminal can be specified as well. ttyname Number of the terminal on which the recipient is logged in. ttyname not specified:
Text to be sent as a message. write reads from standard input one line at a time up to an end-of-file signal:
|
Two-way conversations
Users may communicate interactively by sending messages to each other with write. Conversation between two users proceeds as follows:
|
Error
The addressed user has denied other users permission to write to his/her terminal (see mesg) or his/her terminal is a blockterminal.
Your terminal cannot receive messages from other users (see mesg).
Your terminal cannot receive messages from other users (see mesg).
The user of the other terminal has withdrawn write permission since transmission started (see mesg). |
File
/var/adm/utmp The file in which all logged in users are registered. /usr/bin/sh Command interpreter for lines beginning with !. |
Exit status
0 | Successful completion |
>0 | The addressed user is not logged on or the addressed user denies permission. |
Locale
The following environment variables affect the execution of write: LANG Provide a default value for the internationalization variables that are unset or null. If LANG is unset of null, the corresponding value from the implementation-specific default locale will be used. If any of the internationalization 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 internationalization 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 and input files), the classification of characters as upper- to lower-case, and the mapping of characters from one case to the other. 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 catalogs for the processing of LC_MESSAGES. |
Example
Send a message to user karen:
|
See also
mailx, mesg, pr, sh, talk, who |