Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

write - write to another user

&pagelevel(4)&pagelevel

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.
The command who lists all currently logged-in users and their terminals.

ttyname

Number of the terminal on which the recipient is logged in.

ttyname not specified:
write searches the file /var/adm/utmp for the terminal. If several entries exist because a user is logged in more than once, write uses the first entry recorded in the file. The following message is displayed:

write: user is logged on more than one place.
you are connected to "ttyname".
Other locations are:
        ttyname

        ...

text

Text to be sent as a message. write reads from standard input one line at a time up to an end-of-file signal:

  • A line that begins with an exclamation mark (!) is interpreted as a command; write passes everything that follows the ! in the line to the shell. The command is then executed, while write remains in an active state. Any output that the command writes to standard output will be included in the text to be sent as a message.

  • All other normal lines are sent to the recipient as a message.

  • When write encounters the end-of-transmission character ("EOT \n"), it displays this character on the other terminal and then exits.

  • Non-printing characters (with the exeception of \d, \v, \n, \r and \a) are converted before they are sent.
    Control characters will appear as caret ^<uppercase-letter> . <uppercase-letter> is the letter which results when the 7th bit is set in the ASCII character set.
    For example, ’\003’ is displayed as ’^C’.

Two-way conversations

Users may communicate interactively by sending messages to each other with write. Conversation between two users proceeds as follows:

  1. User A invokes write with the login name of user B. User B receives an announcement (message header) informing him or her that user A wishes to communicate something.

    Message from sender ( terminal ) [ time ]

    User A hears two bell tones to indicate that the connection has been set up and that user B is able to receive.

  2. User B therefore calls write with the login name of user A.

    write sender [ terminal ]

    The message header received by user A serves as an acknowledgement.

  3. Both users can now communicate with one another. Each user should end a message with a distinctive signal so that the other knows when to reply. There should also be a distinctive signal to indicate when the conversation is to be terminated.

  4. The conversation can be terminated by pressing CTRL+D or CTRL+C.
    The command mesg -n can then be used if other users are to be denied permission to write further messages.


Error

user is not logged on. or user is not at "tty"
The addressed user has not logged in.


Permission denied.

The addressed user has denied other users permission to write to his/her terminal (see mesg) or his/her terminal is a blockterminal.


Warning: You have your terminal set to "mesg -n". No reply possible.

Your terminal cannot receive messages from other users (see mesg).


Warning: You are on a Block terminal. No reply possible.

Your terminal cannot receive messages from other users (see mesg).


Can no longer write to ttyname

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

0Successful completion
>0The 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:

$ write karen

!date

Mon Oct 13 19:00:13 MET 2008

Today, at 15.10,

I decided to quit

smoking! CTRL+D

See also

mailx, mesg, pr, sh, talk, who