Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

mesg(1)

login(1)

sh(1)

talk(1)

wall(1)

who(1)

writesrv(8)

utmp(4)

write(1)  —  Commands

NAME

write − Sends messages to other users

SYNOPSIS

write [−r] [−n node] user [line]

write user@node [line]

write −h handle,reply

write −q [−n node]

The write command allows you to converse with another user who is logged in.  The write −r command sends messages to users on other hosts (usually from a shell script) and to wait for replies; use write −h to reply to such messages. 

DESCRIPTION

When two users converse with write, each user alternately sends and receives short messages from their respective ttys. 

For another user to receive your message, that user must be logged in and must not have refused message permission.  When a person you are trying to reach is not logged in, you get the message user is not logged on.  When the person you are trying to reach has refused message permission, you get the message Write: Permission denied. 

When you run the write command, it immediately sends the following message, along with an attention-getting sound (three ASCII BEL characters) to the person whose login name you entered. 

Message from sender on node (ttynn) [date]...

After successful connection, the write command then sends two ASCII BEL characters to your terminal to alert you that whatever you enter now is being sent to the other user.  Sending continues until you enter the End-of-File key sequence, at which point write sends an End-of-Text sequence to the other tty and exits. 

At any point, the other user can respond by sending a write message back.  For this type of exchange, the following convention is useful.  When you first write to others, wait for them to write back before sending any text.  End a message with a prearranged signal (such as o for over) to alert the other user to reply. 

If the ! (exclamation point) character is found at the beginning of a line, write calls the shell to execute the rest of the line as a command. 

When you use the write command to contact a user logged in at more than one tty, write uses the first login instance found in the /var/adm/utmp file as the message delivery point, and you get the message:

user is logged on more than one place.
You are connected to tty.
Other locations are:
tty ...

You can contact this user at another location by specifying the line.  line indicates to which tty (tty00, for example) the message should be sent. 

Permission to use the write command to contact another user is granted or denied by the other user with the mesg command.  Some commands deny message permission while they are running to prevent interference with their output. 

The write command filters nonprintable characters and transmits them in their printed form (that is, ASCII sequence 001 is transmitted as ^A). 

When the write −r command is used to send you a message, you can send a reply of ok, cancel, or query with write −h.  (See FLAGS, EXAMPLES and RETURN VALUES). 

An argument of a − (dash) following the write command allows you to specify a specific tty to which you want to write as the second argument. 

Typing characters from LC_TYPE classifications print or space causes those characters to be sent to the recipient’s terminal. 

FLAGS

Note that writesrv must be running for the −h, −r, and −q features to work. 

−h handle,reply
Replies to a message sent by a utility or shell script with write −r.  The value to be used for handle is generated internally and supplied to you in the text of the original message.  The reply can be ok, cancel, or query.  (See EXAMPLES and RETURN VALUES.) 

−n nodeSpecifies a remote host.  The node field may be a nickname or a node ID.  This flag is used in place of the user@node argument; the two cannot be specified together. 

−qQueries all messages awaiting replies from users on a node and displays them with their handles. 

−rGenerates a message handle, places it in the message header, sends the message, and waits for a reply.  This flag can be used for operator messages and can be put in shell scripts.  It is not used for interactive conversations.  (See EXAMPLES and RETURN VALUES). 

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. 

See writesrv(8) for information on how to start or stop the writesrv daemon. 

EXAMPLES

The following examples assume that the End-of-File key sequence is <Ctrl-d>.  The actual key sequence may be different. 

     1.lucy on tty3 writes a message to sue on the same node:

write sue
Meet me in the computer room at 12:30.
<Ctrl-d>

sue sees:

Message from lucy on node (tty3) [Thu Aug 17 11:55:24 1990]
Meet me in the computer room at 12:30.
<EOT>

     2.Holding a conversation:

write sue
Meet me in the computer room at 12:30.
over

lucy then waits for a response from sue, who replies:

write lucy
I’m running tests at 12:30.  Can we meet at 3?
over

sue then waits for lucy, who replies and terminates:

OK--the computer room at 3.
bye
<Ctrl-d>

sue then terminates their side of the conversation. 

     3.To write someone a prepared message, enter:

write sue <message.text

This writes the contents of the file message.text to sue’s terminal. 

     4.To write to the person using a certain terminal, enter:

write − console
The printer in building 998 has jammed.
Please send help.
<Ctrl-d>

This writes the message to the person logged in on the system console. 

     5.To send a message to user sue at node, enter:

write −n node sue

or

write sue@node

     6.To get a reply to a message, lucy might enter the following:

write −r sue console
Please insert next tape.

sue terminates lucy’s message with

write −h 12345,ok
<Ctrl-d>

or

write −h 12345,cancel

or

write −h 12345,query

sue then terminates as usual. 

Note that with the −h flag, there is no need to supply the hostname or user ID. 

RETURN VALUES

The write −r command is used to send messages to users and to wait for replies.  Their responses determine the exit value:

okExit status 0 (zero). 

cancelExit status 1. 

queryMessage for handle redisplays; write does not exit. 

An exit status of 2 indicates that the user could not be contacted. 

FILES

/var/adm/utmpContains user and accounting information. 

RELATED INFORMATION

Commands:  mesg(1), login(1), sh(1), talk(1), wall(1), who(1), writesrv(8). 

Files:  utmp(4). 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026