Section 9.5. Communicating with Network Users


[Page 347 (continued)]

9.5. Communicating with Network Users

There are several utilities that allow you to communicate with a user:

  • write, which allows you to send individual lines to a user, one at a time

  • talk, which allows you to have an interactive split-screen two-way conversation

  • wall, which allows you to send a message to everyone on the local host

  • mail, which allows you to send mail messages

The mail utility was described in Chapter 3, "GNU Utilities for Nonprogrammers," and supports the full standard Internet addressing scheme. The rest of these utilities are described in this section, together with a simple utility called mesg that allows you to shield yourself from other people's messages.

9.5.1. Shielding Yourself from Communication: mesg

The write, talk, and wall utilities communicate with other users by writing directly to their terminals. You may disable the ability of other users to write to your terminal by using the mesg utility (Figure 9-11).

Figure 9-11. Description of the mesg command.

Utility: mesg [ n | y ]

mesg allows you to prevent other users from writing to your terminal. It works by modifying the write permission of your tty device. The n and y arguments disable and enable writes, respectively. If no arguments are supplied, your current status is displayed.



[Page 348]

In the following example, mesg prevented me from receiving a write message:

$ mesg n          ...protect terminal. $ write glass     ...try to write to myself. write: You have write permission turned off $ _ 


9.5.2. Sending a Line at a Time: write

The write command (Figure 9-12) is a simple utility that allows you to send one line at a time to a named user.

Figure 9-12. Description of the write command.

Utility: write userId [ tty ]

write copies its standard input, one line at a time, to the terminal associated with userId. If the user is logged onto more than one terminal, you may specify the particular tty as an optional argument.

The first line of input that you send to a user via write is preceded by the message:

Message from yourHost!yourId on yourTty 


so that the receiver may initiate a write command to talk back to you. To exit write, type a Control-D on a line of its own. You may disable writes to your terminal by using mesg.


In the following example, I received a write message from my friend Tim and then initiated my own write command to respond. We used the -o- (over) and -oo- (over and out) conventions for synchronization:

$ Message from tim@csservr2 on ttyp2 at 18:04 hi Graham -o-                            ...from tim. $ write tim                      ...initiate a reply. hi Tim -o-                                ...from me. don't forget the movie later -oo-        ...from tim. OK -oo-                                   ...from me. ^D                                ...end of my input. $ _ 



[Page 349]

Although you can have a two-way conversation using write, it's awfully clumsy. A better way is to use the talk utility, which is described next.

9.5.3. Interactive Conversations: talk

The talk utility (Figure 9-13) allows you to have a two-way conversation across a network.

Figure 9-13. Description of the talk command.

Utility: talk userId [ tty ]

The talk command allows you to talk to another user on the network via a split-screen interface. If the user is logged onto more than one terminal, you may choose a particular terminal by supplying a specific tty name.

To talk to someone, type the following at your terminal:

$ talk theirUserId@theirHost


This causes the following message to appear on their screen:

Message from TalkDaemon@theirHost... talk: connection requested by yourUserId@yourHost talk: respond with: talk yourUserId@yourHost 


If they agree to your invitation, they'll type the following at their shell prompt:

$ talk yourUserId@yourHost


At this point, your screen divides into two portions, one containing your keyboard input, and the other containing the other guy's. Everything that you type is echoed at the other guy's terminal, and vice versa. To redraw the screen if it ever gets messed up, type Control-L. To quit from talk, press Control-C.

To prevent other people from talking to you, use the mesg utility.


This is a fun utility that is worth exploring with a friend.

9.5.4. Messages to Everyone: wall

If you ever have something important to say to the world (or at least to everyone on your local host), wall is the way to say it. wall stands for write-all, and allows you to broadcast a message as described in Figure 9-14.


[Page 350]

Figure 9-14. Description of the wall command.

Utility: wall [ fileName ]

wall copies its standard input (or the contents of fileName if supplied) to the terminals of every user on the local host, preceding it with the message "Broadcast Message ...'. If a user has disabled terminal communication by using mesg, the message will not be received unless the user of wall is a super-user.


In the following example, I sent a one-liner to everyone on the local host (including myself):

$ wall                           ...write to everyone. this is a test of the broadcast system ^D                                    ...end of input. Broadcast Message from glass@csservr2 (ttyp2) at 18:04 ... this is a test of the broadcast system $ _ 


The wall command is most often used by system administrators to send users important, timely information (like "System going down in 5 minutes!").




Linux for Programmers and Users
Linux for Programmers and Users
ISBN: 0131857487
EAN: 2147483647
Year: 2007
Pages: 339

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net