Opens a line of communication to send messages to other users on the system in real time.
write -hHandle, { ok | cancel | query } [ -n Host ]
write [ -r ] { [ -n Host ] User | User@Host } [ Line ]
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. For example, while waiting for a response, precede the operating system li command with an ! (!li) and the directory list appears on your workstation. Typing the li command without the preceding ! is interpreted by the system as text to be sent to the target user.
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:
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. |
Notes:
- The writesrv daemon must be running on the target host in order for any of the flags to work. If you are not using either the -n flag or @Host, but using -h, -q, or -r, the writesrv daemon must be running on your host.
- If TCP/IP is not installed on your machine but the HostName is set, in order to converse with users on the local host using the write command with the -h, -q, or -r flag, you must append your host name to the end of the loopback entry in the /etc/hosts file. The original entry should read:
127.0.0.1 loopback LocalHostNameThe new entry should read:127.0.0.1 loopback LocalHostName HostName
This command returns the following exit values:
0 | Successful completion. |
>0 | The addressed user either is not logged on or denies permission. |
write junePress 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 junePress the Enter key and type,
Meet me in the computer room at 12:30. oThis 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.
write karenPresses the Enter key and types,
I'm running tests at 12:30. Can we meet at 3? oAnd you might respond:
OK--the computer room at 3. ooThe 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.textThis writes the contents of the message.text file to june 's workstation.
write -n consolePress 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 spudsPress 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.
write spuds@partyaPress 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,okThen press the Ctrl-D key sequence.
To reply in the negative, enter:
write -h 6398492,cancelThen 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.
/etc/hosts | |
Contains TCP/IP host information. | |
/etc/utmp | |
Contains user and accounting information for the who, write, and login commands. |
The mesg command, wall command, who command, writesrv command.
Shells Overview in AIX Version 4.3 System User's Guide: Operating System and Devices.