Opens a line of communication to send messages to other users on the system in real time.
To query all messages awaiting replies from users on a host and display them with their handles, type the following:
To Reply to a Message Sent by a Utility or a Shell Script, or Redisplay the Message Associated with a Given handle, type the following:
write -hHandle, { ok | cancel | query } [ -n Host ]
To send messages to a user, optionally on another host or a particular device, type the following:
The write command enables message sending over the system in real time. It provides conversation-like communication with another logged-in user. Each user alternately sends and receives short messages from the other workstation. Long messages can be sent by putting the complete message in a file and then redirecting that file as input to the write command.
For another user (as specified by the User parameter) to receive a message, that user must be logged in and must not have refused message permission. When a message is sent to a user who is not logged in, the message user not logged in appears. If the message is sent to a user who has refused message permission by setting the mesg command to no, the message write: permission denied appears.
When the write command is issued, it immediately sends the following message, along with an attention-getting sound (the ASCII BEL character) to the message recipient or target:
Message from SenderID on SenderHostname (ttynn) [Date] ...
With a successful connection, the write command sends two ASCII BEL characters to both workstations. The beep alerts the sender that the message can begin and it alerts the receiving user that a message is coming.
Sending occurs one line at a time as the Enter key is pressed. The communication link from the sender to the receiver remains open and sending continues until the Ctrl-D key sequence ends the sending link. Then an end-of-text character (<EOT>) is sent to the target workstation and the write command mode is terminated.
The receiving or target user can respond by sending a write command to the originating user. This opens a line of communication from the receiver back to the sender, enabling message responses in return. For this type of exchange, the following convention is useful: When you first write to others, wait for a response before sending any text. End a message with a signal such as o (over) to alert the other person to reply. Use oo (over and out) when the conversation is finished.
If the character ! (exclamation point) is found at the beginning of a line, the write command calls the shell to execute the rest of the line as a command.
When you write to a user who is logged in at more than one workstation or multi-using more than one process, the write command uses the first login instance found in the /etc/utmp file as the message delivery point (usually the login or console shell), and you get the message:
UserID is logged on more than one place.
You are connected to "Workstation".
Other locations are:
Workstation
When this message is received, if you wish to send the message to a location other than the initial login location, the target user can be contacted at a different location by specifying the Line of the location (tty00, for example).
Permission to write to another user is granted or denied by the individual user with the mesg command. Some commands deny message permission while they are running to prevent interference with their output. A user with root user authority can write to any workstation regardless of the workstation's message permission.
You can use the write command to converse with users on other hosts. You can identify a user on a remote host by using the -nHostName flag or the User@Host parameter. In order to write to a user on a remote host, the writesrv daemon must be running on both the current host and the remote host.
The write command is also used by the qdaemon daemon to send messages to users on other hosts and to wait for replies. There are only three valid replies:
Item | Description |
---|---|
ok | The original write exits with a status of 0. |
cancel | The original write exits with a status of 1. |
query | The message associated with the given handle is displayed. |
Item | Description |
---|---|
User | Specifies the user ID of the person to receive the message text. |
User@Host | Specifies the user ID and remote host of the person to receive the message text. |
Line | Contacts the target user at another location (tty00, for example). |
Item | Description |
---|---|
-h Handle,Reply | Replies to a message sent by a utility or shell script using write with the reply option. The value to be used for the Handle variable is generated internally and supplied to the user in the text of the original message. The reply can be ok, cancel, or query. |
-nHost | Specifies a remote host. The Host variable may be a nickname or an internet address. |
-q | Queries all messages awaiting replies from users on a host and displays them with their handles. |
-r | Generates a message handle, places it in the message header, sends the message, and waits for a reply. This flag is used by the qdaemon daemon for operator messages and can be put in shell scripts. It is not used for interactive conversations. An exit status of 0 indicates that the reply was ok, a status of 1 indicates that the reply was cancel, and an exit status of 2 indicates that the user could not be contacted. |
127.0.0.1 loopback LocalHostName
The
new entry should read: 127.0.0.1 loopback LocalHostName HostName
This command returns the following exit values:
Item | Description |
---|---|
0 | Successful completion. |
>0 | The addressed user either is not logged on or denies permission. |
write june
Press
the Enter key and type, I need to see you! Meet me in the computer room at 12:30.
Then
press the Ctrl-D key sequence to terminate the write command
mode.If your user ID is karen and you are using workstation tty3, june's workstation displays:
Message from karen on trek tty3 Aug 17 11:55:24 ...
I need to see you! Meet me in the computer room at 12:30.
<EOT>
write june
Press
the Enter key and type, Meet me in the computer room at 12:30.
o
This starts the conversation. The o at the
beginning of the next line means the message is over. It tells June
that you are waiting for a response. Do not press Ctrl-D if you wish
to continue.Now June replies by typing:
write karen
Presses the Enter key and types,
I'm running tests at 12:30. Can we meet at 3?
o
And you might respond: OK--the computer room at 3.
oo
The oo means over and out, telling
June that you have nothing more to say. If June is also finished oo,
then you both press Ctrl-D to end the conversation.write june < message.text
This
writes the contents of the message.text file to june's
workstation.write -n console
Press
the Enter key and type, The printer in building 998 has jammed.
Please send help.
Then press the Ctrl-D key sequence.This writes the message to the person logged in at the workstation /dev/console.
write -n partya spuds
Press
the Enter key and type, Your new tape has just arrived,
come see me to pick it up.
Thanks!
Then press the Ctrl-D key sequence.OR
write spuds@partya
Press
the Enter key and type, Your new tape has just arrived,
come see me to pick it up.
Thanks!
Then press the Ctrl-D key sequence.Message from mary on trek (tty10) Aug 17 10:03:34 ...
Use "write -h 6398492,reply" to reply
Please insert tape number 5 into rmt0.
<EOT>
To reply in the affirmative, enter: write -h 6398492,ok
Then press the Ctrl-D
key sequence.To reply in the negative, enter:
write -h 6398492,cancel
Then press the Ctrl-D
key sequence.With the -h flag, there is no need to supply the host name or user ID. This information is tracked with the handle.
Item | Description |
---|---|
/etc/hosts | Contains TCP/IP host information. |
/etc/utmp | Contains user and accounting information for the who, write, and login commands. |