This chapter describes how to send or receive messages over the network by using one of the following commands:
Examples in this chapter use the mailx program rather than Mail. Using mailx, you can do the following tasks:
Using mailx you can also send entire files, a task described in Chapter 12, "Copying Files to Another Host."
The Digital UNIX mailx or Mail command accesses the same mail program as the ULTRIX mail (that is, /usr/ucb/mail) command. Refer to Chapter 2 of the ULTRIX to Digital UNIX Migration Guide for more information.
The write and talk commands work interactively; the recipient must be logged in. Before using these interactive commands, you can verify the name and availability of a user or host by using the following commands described in Chapter 10:
Using mailx, you can send a message to one or more users at the following locations:
Use the following syntax for the mailx command:
mailx user [ @ { host | domain | host.domain } ] ...
To send mail to users on the local host, enter the mailx command and specify a user parameter for each user. For users on remote hosts, you must specify additional information about the location of the host after the "at sign" (@).
For example, to send mail from host orange to users smith and jones on the same local host, you would enter the following command:
orange%
mailx smith jones
To send mail to user hobbes on a different host, pluto, in the same domain, you would enter the following command:
orange%
mailx hobbes@pluto
In the preceding example, if user hobbes were in another domain called planets, you would add the name of the remote network domain, as shown in the following command:
orange%
mailx hobbes@pluto.planets
The domain is sometimes split into further subdivisions with the name of each separated by a period (.) in the destination name. Depending on how the network has been configured by the network administrator, you can address a user on a remote host in another domain by specifying only the domain name, as in the following command:
orange%
mailx hobbes@planets
If necessary, see your system administrator for help addressing a mail message.
This section explains how to use mailx to send a message to a user on a local host and a copy of the message to other users. To begin the example, user Jones enters the mailx command at the local system prompt, orange%:
orange%
mailx suzuki [Return]
After pressing the Return key, the Subject: prompt displays. Pressing the Return key again immediately would leave the subject blank. Instead, user Jones enters the subject of the message before pressing the Return key, and then begins writing the message:
Subject:
Baseball question [Return]
Are there any Japanese baseball simulation games?
I want to compare Sadharu Oh's hitting statistics
to those of Hank Aaron. To do this, I need to set
up a simulated baseball season having each hitter
play for one year in the other player's league.
User Jones ends the message by typing a period (.) on a blank line, followed by the Return key, as shown:
.
.
.
play for one year in the other player's league.
. [Return]
Cc:
In this example, the message has not yet been sent; instead the Cc: (that is, "carbon copy") prompt appears because user Jones has customized his mail session by adding set askcc to the .mailrc file in his home directory. (See Section 11.6 and Appendix D on customizing your mail session.)
The Cc: prompt enables you to send copies to other users. If you choose not to, press the Return key to exit mailx, and send the message; the end-of-text message (EOT), then appears followed by the system prompt.
In this example, user Jones sends copies to local user cranton and remote users gillis and vincep by entering the appropriate address for each at the Cc: prompt and pressing the Return key to exit mailx and send the message:
.
.
.
Cc:
cranton gillis@strato vincep@mlb.bbs.com [Return]
EOT
orange%
The mailx program enables you to recover from addressing errors. For example, if your intended recipient on the local host is cranton, but you mistakenly type crantom, the following message appears immediately on your screen,
crantom... User unknown
and the message is mailed back to you. You can then save and resend it to the right person.
If you send a message to an unknown person on a remote host, it may take as long as three days before mailx sends it back to you. Section 11.3.3.1 explains how to save and resend a returned message.
To edit a mail message before sending it, after replying to the Subject: prompt, enter one of the following escape commands to activate an editor within mailx:
To use the ~e command from within mailx to activate a text editor, enter ~e as the first two characters on a new line - you may need to type the tilde (~) a few times before it displays. For example:
Subject:
network documentation meeting at 2 PM
Everyone, please bring the Table of Contents
for your book so that we can look for areas
of overlapping subject matter and
~e
If your
.mailrc
file contains
set EDITOR=/usr/ucb/vi,
you can now use the
vi
editor to correct the spelling mistake in the first line
and finish writing the message.
When you end the editing session, you are back in
mailx.
You can end the message and exit
mailx
or re-invoke
vi
and continue writing.
You may decide not to send a message that you have started. There are two ways to abort a message before sending it.
You can abort a mail message by pressing Ctrl/c twice, anywhere within a message. When you first press Ctrl/c, the following message is displayed:
(Interrupt -- one more to kill letter)
You can now reconsider your decision to abort the message. If you decide not to abort it, continue entering text. If you decide to abort the message, press Ctrl/c again, and the following message will be displayed:
(Last Interrupt -- letter saved in dead.letter)
The message is aborted, you exit mailx, and the system prompt is displayed.
By default, the aborted message is saved in the dead.letter file in your home directory. If you choose not to save aborted messages, you can enter set nosave in your .mailrc file. See Section 11.6 and Appendix D for more information.
Only the most-recently aborted message is saved in the dead.letter file. You can edit and resend it by including it within a mail message. (See Section 11.2.3 for information on including files within messages.)
The following example shows how to abort a mail message by pressing Ctrl/c:
orange%
mailx sally
Subject:
Update to reference page files
What should the mailx(1) reference page include
about sending to remote users?
[Ctrl/C]
(Interrupt -- one more to kill letter)
[Ctrl/C]
(Last Interrupt -- letter saved in dead.letter)
orange%
You can abort a mail message by entering either the ~q or the ~x escape command on a blank line. Unlike aborting a message by pressing Ctrl/c, these commands abort the message immediately, without prompting you to reconsider. The ~q escape command saves the aborted text in the dead.letter file in your home directory, but ~x does not, even if you have set save in your .mailrc file. The following example shows how to abort a mail message by using the ~x escape command:
orange%
mailx sally
Subject:
Update to reference page files
What should the mailx(1) reference page include
~x
orange%
You may need to enter the beginning tilde character (~) a few times before it appears.
You can include any file (except an unconverted binary file) within a mail message. You will do this often when you save and resend any incorrectly-addressed mail that is returned to you (See Section 11.3.3.1) or when you edit and resend an aborted message saved in the dead.letter file in your home directory.
From an example in the previous section, the dead.letter file contains the following text:
What should the mailx(1) reference page include about sending to remote users?
Suppose that you want to resend this file to user sally after adding additional information. While in mailx, use the ~d escape command to automatically add the text of dead.letter to the mail message, regardless of the current working directory.
The following example starts a message to user sally before adding the text of dead.letter through the ~d command:
orange%
mailx sally
Subject:
the mailx(1) reference page
The uucp(1) reference page has formatting
information for sending to remote users.
~d
"/usr/staff/r2/sally/dead.letter" 2/76
After including the file, its full path name is displayed, with the number of lines (2) and characters (76) that the file contains (including the Return key or a control character at the end of each line). After the display, you can exit or continue writing your message, but you may want to enter a text editor (for example, by typing ~v for vi) to look at the included file, which is not displayed otherwise.
Note
The dead.letter file contains only the most-recently aborted mail message. You may want to verify that it contains the text that you want to send.
To include a file (including dead.letter) within a mail message, you can use either of two escape commands, ~< or ~r followed by the file name. These commands work in the same way. If the file is not in the same directory from which you entered mailx, you must precede the file name with a full path name or one that is relative to the current directory.
The following example uses the ~< escape command to include a file called strato_prob from the environ directory below the current working directory:
orange%
mailx sally
Subject:
Dan, here's the stratosphere data file
~< environ/strato_prob
"environ/strato_prob" 41/1309
See Section 12.1.3 for information about transferring a file non-interactively through the mailx utility.
When you receive a mail message, you have the following options:
The mailx program notifies you if you have new mail when you log in, enter any operating system command, or press the Return key. You can also enter the mailx command at the system prompt to see if you have new mail.
In the following example, user Jones on host orange enters mailx and finds two messages waiting:
orange%
mailx
Mail $Revision: 1.1.9.4 $ Type ? for help.
"/usr/spool/mail/jones": 2 messages 1 new 1 unread
U 1 root Mon Jul 20 10:39 14/438 "System news"
>N 2 root Mon Jul 20 11:30 11/292 "Welcome"
?
In this example, two messages are waiting from the system administrator (root); one is unread (denoted by U in column 1) from a previous mailx session and the other is new (denoted by N). The question-mark (?) at the end of the message is the mailx prompt. You can type another question-mark at this prompt to display a list of available mailx commands, as indicated in the header and as described in Section 11.4.
You can press the Return key at the mailx prompt to read message 2, which is indicated by the right-angle bracket (>), in the list of waiting messages. For example,
?
[Return]
Message 2:
From root Wed Aug 4 11:17:36 1996
Date: Wed, 4 Aug 1996 11:17:29 -0400
From: root (system administrator)
To: jones
Subject: Welcome
Welcome to the company computer network. I'm the
person who manages this system. If you have
questions or problems, send mail to root. You
can also send mail to manager or admin; messages
will be forwarded to me.
I will be on vacation for the next two weeks after
this week... starting Monday, August 10. I'll be
stdin
[Space]
back on Monday, August 24.
?
In this example, stdin displays because the PAGER variable has been set to more (the default). If the PAGER variable had been set to pg nothing would have been displayed. Also in the above example stdin appears after the 15th line of the message because user Jones has customized the mailx environment by adding set crt=15 to the .mailrc file. In the .mailrc file, set crt= specifies the number of lines to display at one time before invoking the pager (either pg or more). to display the remainder of the message. As shown in the example, because the message is more than 15 lines long, set crt instructs mailx to invoke the pager after 15 lines. By pressing the Space bar, the next screen full of the message are displayed. You should customize your mailx environment by using set crt=. Otherwise, long mail messages will scroll rapidly, requiring you to quickly press the Hold Screen key. See Section 11.6.2 and Appendix D for more information on customizing mailx. To read another message, enter the message number at the mailx prompt. To list the messages again, enter h at the mailx prompt. In the following example, user Jones uses the h command to list the mail messages, sees that the first message is still unread, and enters a 1 at the ? prompt to read it:
?
h
U 1 root Mon Jul 20 10:39 14/438 "System news"
> 2 root Mon Jul 20 11:30 11/292 "Welcome"
?
1
Message 1:
From root Mon Jul 20 11:30:07 1996
Date: Mon, 20 Jul 1996 11:30:04 -0400
From: root (system administrator)
To: jones
Subject: System news
The newest release of the text processing
software will be installed after 5 o'clock
today. Send mail if you have questions or
concerns before or after the installation.
?
The message you are reading is called the current message. To reread it, enter a period (.) at the mailx prompt. To read the next message, press the Return key. This message becomes the current message. You can read all your messages in succession by pressing the Return key after each message.
Your messages stay in mailx until you delete them before or after storing them in a file or in a folder. To delete the current message after reading it, enter the d (delete) command at the mailx prompt. To delete a different message, enter the d command at the mailx prompt, followed by the message number. You can delete several messages by listing their numbers after the d command. For example, enter the following command at the mailx prompt to delete messages 7 and 9:
?
d 7 9
You can also delete a range of messages by using a hyphen between the first and last message. For example, to delete messages 7 through 11, enter the following command at the mailx prompt:
?
d 7-11
If you accidentally delete a message, you can recover it with the u (undelete) command. For example, to undelete message 7, enter the following command at the mailx prompt:
?
u 7
If you exit mailx by entering q or quite instead of x, any previously read messages that you do not delete are added to the end of a file of previously undeleted messages named mbox, in your home directory.
Replying to a mail message is similar to sending a mail message. You have the same options to edit, abort, or include a file in a message, as described in Section 11.2.
To reply to the sender of a message that you have just finished reading, enter an uppercase R (reply) command at the mail prompt, as shown in the following example:
Message 3:
From deedee Mon Jul 20 14:13:32 1996
Date: Mon, 20 Jul 1996 14:13:05 -0400
From: deedee (DeeDee Smith)
To: jones, mays@sf24.usernet, susannah@artwrk
Subject: Testing text-processing software
I think we should test the new text processing
software on the older machines as well as the
newer. Remember that many customers still have
the older models.
?
R
To: deedee
Subject: Re: Testing text-processing software
I agree. Also, we should test different machine
configurations to determine if, for example,
it performs satisfactorily when run remotely.
.
EOT
?
After you enter R, the recipient and subject line display, enabling you to verify that you are replying to the intended recipient.
If you enter a lowercase r, the reply will be sent to the recipients of the original mail as well as to the sender; in this example, to mays@sf24.usernet and susannah@artwrk, as well as to deedee.
Note
To reply only to the sender of a mail message, enter an uppercase R at the mail prompt. To reply to the sender and all recipients of a mail message, enter a lowercase r at the prompt.
In the preceding example, the Cc: prompt does not appear because user jones' .mailrc file does not contain the set askcc command.
If you leave mailx by entering the q command (instead of the x or exit command), the messages that you have just read are stored in the mbox file in your home directory. You can read this file by using the more or cat command, or you can use a text editor to read and edit it.
To store mail messages in a more useful way, you can save them in individually-named files or in folders as described in the following sections.
There are several kinds of mail that you might want to save in a file:
To save a brief message that you read or a mail message that mailx returned to you, enter the s command at the mailx prompt and supply a name for the file.
A returned message is shown in the second item in the following output from the mailx command:
orange%
mailx
Mail $Revision: 1.1.9.4 $ Type ? for help.
"/usr/spool/mail/jones": 2 messages 1 new 1 unread
U 1 root Mon Jul 20 10:39 14/438 "System news"
>N 2 MAILER-DAEMON Wed Aug 5 09:39 19/498 "Returned mail: User unknown"
?
As shown below, user Jones decides to save the returned message from the previous example in the file, verify-resend, as a reminder to find the correct address before resending it.
.
.
.
>N 2 MAILER-DAEMON Wed Aug 5 09:39 19/498 "Returned mail: User unknown"
?
s verify-resend
The file, verify-resend, is saved in the current directory unless an explicit pathname is specified. For example, user Jones could have saved it in a subdirectory called fix-later by entering the following command:
?
s fix-later/verify-resend
To save a long message without reading the entire text online, press Ctrl/c to stop the message from scrolling and to display the mailx prompt. You can now save (or delete) the message. In the following example, user Jones receives a 20-page report in message 1, and presses Ctrl/c to access the mailx prompt where a command is entered for saving the file:
?
1
Message 1:
From smith Wed Aug 5 16:43:42 1996
Date: Wed, 5 Aug 1996 16:43:41 -0400
From: smith (Cassandra Smith)
To: jones
Subject: 20-page report: host configuration results
Mortimer,
Here's the report on host configuration that the
[Ctrl/c]
Interrupt
?
s sys-config-report
"sys-config-report" [New file] 2147/48353
?
dp
.
.
.
In the example above, after creating the file, user Jones enters dp (that is, delete-proceed) at the mailx prompt to prevent the large 20-page file from being saved in mbox, and to start reading the next mail message. Otherwise, the mailx command, d (delete) and pressing the Return key could have been entered to do the same.
To organize messages for easier reference and to minimize the size of the mbox file (which is a folder itself) you can save messages in files called folders. Before using a folder other than mbox, you must create a folder sub-directory in your home directory and add a pointer to the folder in your .mailrc file. For example, if you make a directory named folder in your home directory, you must add the following line to your .mailrc file: set folder=folder.
To add a message to a folder, use the mailx command, s and the folder name. For example, to save a message about host configuration with other messages on that topic, write it to a folder named sys-config, as follows:
Message 7:
From smith Thu Aug 6 09:32:09 1996
Date: Thu, 6 Aug 1996 09:32:08 -0400
From: smith (Cassandra Smith)
To: jones
Subject: host configuration testing
According to the report that each LAN ...
?
s sys-config
"sys-config [New file] 11/235
When you save the first message in a folder, mailx stores it and displays the message, New file. If you save more messages in that folder, mailx appends them to the end of the file and displays the message, Appended.
There are two ways to read messages stored in a folder other than mbox:
orange%
mailx -f sys-config
?
folder meetings
When you switch folders, mailx makes any changes to the folder you are leaving before it opens the new folder.
You can use the folder command without arguments to find out what folder you are in. For example:
?
folder
"sys-config": 17 messages
You can use the m command and the ~f escape command in mailx to forward to other users any message that you receive. The following example shows how to start message forwarding to user deedee:
?
m deedee
Subject:
forwarding a message
For example, to forward message number 3 to user deedee and include a subject line and introductory note, you would enter the following text:
I received this note from Gary. Do you agree?
~f 3
Interpolating: 3
(continue)
.
EOT
As shown, after you enter the ~f command, you can continue writing or end the message. To forward the current message, do not enter a number after the ~f.
When you enter mailx and messages are waiting, the following line is displayed at the top of the header:
Mail $Revision: 1.1.9.4 $ Type ? for help.
This is a reminder that you can type a question mark (?) at the mailx prompt to display a brief description of available mailx commands, as shown in Example 11-1.
?
?
Control Commands: q Quit - apply mailbox commands entered this session. x Quit - restore mailbox to original state. ! <cmd> Start a shell, run <cmd>, and return to mailbox. cd [<dir>] Change directory to <dir> or $HOME. Display Commands: t [<msg_list>] Display messages in <msg_list> or current message. n Display next message. f [<msg_list>] Display headings of messages. h [<num>] Display headings of group containing message <num>. Message Handling: e [<num>] Edit message <num> (default editor is e). d [<msg_list>] Delete messages in <msg_list> or current message. u [<msg_list>] Recall deleted messages. s [<msg_list>] <file> Append messages (with headings) to <file>. w [<msg_list>] <file> Append messages (text only) to <file>. pre [<msg_list>] Keep messages in system mailbox. Creating New Mail: m <addrlist> Create/send new message to addresses in <addrlist>. r [<msg_list>] Send reply to senders and recipients of messages. R [<msg_list>] Send reply only to senders of messages. a Display list of aliases and their addresses. ============================ Mailbox Commands ==========================
There are three commands you can use to exit from mailx:
When setting up an account for a new user, the system manager defines certain mailx default settings in the /usr/share/lib/Mail.rc file. As supplied by the operating system, this file contains the following mailx settings, which a user can override:
You can customize your mailx session by defining aliases and setting variables in the .mailrc file in your home directory. Here is a sample .mailrc file:
alias sue susannah alias wombats tom, jeff, craig, jim, ken set ask set askcc set prompt=> unset dot set record=/usr/users/hale/outgoing set folder=folder set crt=20
You can use the alias command in mailx to create alternate names for users or user groups.
Note
The mailx alias is not the same alias command used by the shell; you cannot use it to modify mail commands.
To define a permanent mail alias, enter the alias command in the .mailrc file, specifying the alias name and one or more login names. The following .mailrc file defines two aliases:
alias sue susannah alias wombats tom, jeff, craig, jim, ken
The first alias defines the name sue to mean user susannah. This enables you to send mail to susannah by using the name sue. The second alias enables you to send mail to members of a team called the Wombats - tom, jeff, craig, jim, and ken, by addressing your message to wombats. Another way to enter this line in .mailrc is this:
alias wombats tom,\ jeff,\ craig,\ jim,\ ken
The backslash
(\)
enables you to write a single long command on several lines.
While in mailx, you can see what aliases are defined by using the alias command without arguments. You can also define temporary aliases at the mailx prompt that are in effect during that mailx session.
Mail variables are similar to variables in your .login file. They can be binary, string, or numeric.
To set a binary mail variable in your .mailrc file, enter the set command followed by the option name. The sample .mailrc file includes these binary variables:
set ask set askcc unset dot
String mail variables accept characters or numbers as values. The sample .mailrc file includes the following three string variables:
set folder=folder set record=/usr/users/hale/folder/outgoing set crt=20
orange%
mail -f outgoing
An alternative to the mailx program is the Message Handling program (MH). The MH program is a set of small mail-handling programs that you use by entering the command you want to execute from the shell prompt.
The MH program is optional; it may not be installed on your host. To determine if MH is available, look for the /usr/bin/mh directory.
To use MH, you must add the /usr/bin/mh directory to your path by editing the set path line in your .cshrc or .login file. Then, notify the shell about the change in your path by logging out and logging back in, or by entering the following command (for the C shell):
orange%
source .login
If your path is set in .cshrc, use .cshrc instead of .login in this command. For either the Bourne or Korn shell, you would add this information to the .profile file and notify the shell by entering the following command:
orange$
. .profile
With the MH program, folders are organized differently from mailx folders. New and unread mail is kept in a folder called inbox, into which you move the mail that arrives in your system mailbox by using the inc command. You must enter the inc command every time you want to include new mail.
You select a folder with the folder command. If you enter it without a folder name, folder displays the currently selected folder.
You can enter the folder command with the -all option to display a list of your folders and the number of messages in each.
You use the show, prev, and next commands to read the current, previous, and next messages in your current folder. If you enter a message number with the show command, that message becomes your current message. For example:
orange%
show 7
Message 7:
From deedee Mon Jul 23 10:02:10 1996
Date: Mon, 23 Jul 96 10:01:25 edt
To: hale
Subject: Cafeteria hours
Cc:
Status: R
I'm sorry you didn't ask that sooner. The cafeteria
closes its breakfast service at 10. Lunch starts
at 11:30.
The rmm command removes messages from your current folder. If you use the rmm command with no argument, it deletes the current message. If you specify one or more message numbers, the messages you specify are removed. For example, to remove messages 2, 5, and 7, enter the following command:
orange%
rmm 2 5 7
Table 11-1 lists most of the MH commands. For a complete list, see the mh(1) reference page. For more information about each MH command, see the reference page for each.
Command | Description |
ali | Searches the specified alias files and displays the addresses corresponding to the specified aliases. |
anno | Annotates messages to keep track of distribution, forwarding, and replies for your messages. |
burst | Extracts the original messages from a forwarded message, discards the forwarding header, and places the original messages at the end of the current folder. |
comp | Creates a new mail message, providing a template for you to fill in and invoking an editor to finish the message. |
dist | Redistributes the current message to addresses that are not on its original distribution list. |
folder | Selects a folder or displays the contents of your current folder. |
folders | Lists all your folders and the number of messages each one contains. |
forw | Forwards messages to recipients who were not the original addressees. The message is encapsulated (included with a "Forwarded message" notice) and a header is added. |
inc | Incorporates mail from your system mailbox into your inbox folder. |
mark | Assigns a name to a sequence of messages in your current folder. You can then use the pick command to select messages marked in this way. |
mhl | Lists formatted MH messages. You can use this command as a replacement for the more command to display messages. |
mhmail | Sends mail to the specified users. If you do not specify any users, mhmail works like the inc command. |
msgchk | Checks your system mailbox and any other files that can receive new mail for you, looking for new messages. If any new messages are found, msgchk reports. |
next | Displays the next message in the current folder or in the specified folder. |
packf | Compresses a folder into a single file. (Each message is normally stored as a separate file.) Do not confuse the packf command with the pack command. |
pick | Selects messages based on content, sequence name, or other criteria. |
prev | Displays the previous message in the current folder. |
prompter | Invokes a simple editor designed for composing messages. The prompter command is invoked by comp, dist, forw, and repl; you do not need to call prompter directly. |
rcvstore | Incorporates a message from the standard input directly into a folder. |
refile | Moves messages from the current folder to one or more other folders. |
repl | Replies to either the current message or the message you specify. |
rmf | Removes all of the messages in a folder and then removes the folder itself. |
rmm | Removes messages from a folder. The message files are not actually destroyed; instead, rmm renames them by inserting a number sign (#) as the first character of the file names. On most hosts, files whose names begin with a number sign are deleted once a day by an automatic process. Until they are actually deleted, you can recover removed messages by using the mv command to rename the files. |
scan | Displays a list of the messages in a folder. |
send | Sends a message that you have created by using comp, prompter, or another editor. |
show | Displays the contents of a message. |
sortm | Sorts messages in a folder into chronological order according to the Date: field of the message header. |
whatnow | Prompts you for what to do with a message you have just composed. You can reexamine an original message to which you are replying, resume editing the new message, or do other tasks associated with sending the message. |
whom | Expands the header of a message into a set of addresses and optionally checks to see that the message can be delivered to those addresses. |
The following example shows how the MH msgchk command reports new messages:
orange%
msgchk
You have new mail waiting, last read on
date
You can tailor the features of MH by creating a .mh_profile file in your top-level directory. The MH reference pages describe the features that you can modify.
The write command enables two users on the same or different hosts to communicate on either a video display terminal or on nonvideo devices (for example, a teletypewriter) that print messages on paper.
You can use write to send a message immediately to someone who you cannot reach by telephone, especially if you do not require a reply. (See also the talk command in Section 11.9.)
The write command displays a message on the terminal screen of the recipient. You can prevent users from communicating with you through write and talk by entering the mesg n command in the .login file in your home directory. You cannot disable incoming messages from those with superuser privileges.
To determine whether a user on a local host has disabled messages from write and talk, use the finger command and look at the first line of output for the phrase messages off. For example:
Login name: smith (messages off) In real life: John Smith
.
.
.
For users on a remote host, the disabling of write and talk is denoted by an asterisk (*) in the TTY field of the output line, for example:
.
.
.
Login Name TTY Idle When Office chang Peter Chang *p1 2:58 Thu 10:16 103
See Section 10.2.2 and finger(1) for more information. Your intended recipient may be running a command that temporarily disables write to prevent its interference, and the sender would receive the message,
Write: Permission denied
just as if the recipient had explicitly disabled write.
You can use the write command only when the recipient is logged in. Use the who command, as described in Section 10.1, to list current users. If, for example, user smith is not logged on when you send a message through write, the following message is displayed on your terminal screen:
smith is not logged on
The following steps show how user wang sends a message to user chung, both of whom are logged in on local host dancer:
dancer%
write chung
The write program rings a bell and sends the following message to the terminal screen of chung:
message from wang tty04 Feb 14 10:32:45
A bell rings user wang's terminal when the connection is made.
The double-sided lab printer is working. [Return]
Re-send your job, and I'll check it. [Return]
[Ctrl/d]
Note
See your system administrator if pressing Ctrl/d does not produce the EOF signal on the recipient's screen or if a bell does not ring on the sender's terminal.
You can use the exclamation point (!) at the beginning of a new message line to access the shell prompt and execute any operating system command (including write). For example, if wang forgot the name of the current directory from which chung is to retrieve certain files, wang can enter the !pwd command to remind himself, as shown:
dancer%
write chung
You can copy the network user files from: [Return]
!pwd [Return]
/ufs/usr/staff/r0/net-dir/network_comm
!
/ufs/usr/staff/r0/net-dir/network_comm
[Ctrl/d]
dancer%
The write command can be used interactively, but it is difficult for both sender and receiver to determine when the other has finished and is waiting for a reply. For example, wang can enter the following command:
dancer%
write chung
Wang will then wait for chung to reply, but chung might also wait, thinking that wang intends to continue the message.
To minimize problems, it is a good idea to establish a simple, temporary protocol each time you want to use write interactively. For example, user wang can start his message to chung as follows:
dancer%
write chung
I'll mark the end of each message with 'ZZZ' [Return]
and wait for a reply. Please do the same. [Return]
I'll install a driver for the new printer. [Return]
Do you want to test it? ZZZ [Return]
For more information, see the write(1) reference page.
The talk command enables a user to send a message to another user on the same or on a remote host, interactively and more easily than through write. However, talk works only on video display terminals.
Like write, you can use talk to send a message immediately to someone who you cannot reach by telephone. Also, like write, the talk command may disrupt the receiver because it sends a notification message directly to a terminal and continues doing so until a reply is entered.
To disable incoming messages (except from those with superuser privileges) from talk (and from write, as described earlier) you can put the command, mesg n in your .login file. To determine whether a user has done this, use the finger command as described in Section 10.2.1 or in the finger(1) reference page.
During an online talk session, a "send window" and a "receive window" are opened on each user's terminal. Each can type into the send window while talk displays in the receive window what the other user is typing.
For example, to send a message to user hoover on the same local host apple, user coolidge enters the following talk command:
apple%
talk hoover
The program then divides the terminal screen of coolidge into two parts; the top half assigned to coolidge and the bottom half assigned to hoover.
Next, the following message is displayed in the top of the screen:
[No connection yet]
When the connection is established, the following message is displayed:
[Waiting for your party to respond]
After this message, a bell rings on hoover's terminal and the following message is displayed:
Message from Talk_Daemon@apple at 16:18 ... talk: connection requested by coolidge@apple talk: respond with: talk coolidge@apple
If hoover does not respond quickly, the following message is displayed on coolidge's screen:
[Ringing your party again]
When hoover responds, a message about the established connection appears on coolidge's screen. Each user can now enter text. If the screen fills up, talk overwrites the text at the beginning of the screen. Either user can end the conversation by pressing Ctrl/c. The end of the talk session is marked as follows:
[Connection closing. Exiting]