start page | rating of books | rating of authors | reviews | copyrights

Book HomeLearning UnixSearch this book

6.7. Interactive Chat

Need a quick answer from another user without sending an email message and waiting for his reply? Want to have a conversation with your Internet-connected friend in Chile but don't have money for an international phone call? An interactive chat program lets you type text to another user and see her reply moments later. Chatting, or "instant messaging," has become popular recently. Widely known chat programs are available for Unix; as of this writing, those include Jabber and AOL Instant Messenger. Other programs have been available on Unix systems for years. We look at two of these: talk and IRC.

6.7.1. talk

The talk program is simple to use. Give the username (and, optionally, the hostname) of the person you want to chat with. Then talk will try to notify that person as well as show how to use talk to complete the connection with you. Both of your terminal windows will be split into two sections, one for the text you type and the other for the text you get from the other person. You can type messages back and forth until one of you uses CTRL-C to break the session.

One advantage of talk is its simplicity; if each of you has a terminal window open, either of you can run the program at any time; if the other person is logged in, he is notified that you want to chat and told how to complete the connection. If both people want to use talk on the same computer--even if one of them is logged in remotely (see Section 6.1, earlier)--it should work well. Unfortunately, there are several talk versions that don't work with each other. So, the first time you try to chat with someone on another host, which might have another talk version (or other problems), it can take planning. Use an email message or phone call to alert them that you'll try talking soon, then experiment to be sure that both of you have compatible talk systems. After that, you're all set.

Here's the syntax:

talk username@hostname

If the other user is logged onto the same computer as you, omit the @hostname. After you run that command, your screen clears with a line of dashes across the middle. The top half shows text you type and informational messages about the connection. The bottom half shows what the other user types.

For example, if your username is juan, you're logged onto the computer sandya.unm.edu, and you want to talk to the user ana at the computer cielo.cl, you would type "talk [email protected]". If the connection works, your screen clears and you'll see something like Figure 6-12.

Figure 6-12

Figure 6-12. A successful talk connection

The message [Waiting for your party to respond] means that your talk program has found ana's system and is waiting for her to respond. Ana's terminal bell should ring and she should see a message like this in one of her terminal windows:

Message from [email protected] at 18:57 ...  
talk: connection requested by [email protected].
talk: respond with:  talk [email protected]

If she answers by typing talk [email protected], the connection should be completed, and her screen should clear and look like Juan's. What she types appears on the top half of her screen and the bottom half of Juan's, and vice versa. It's not always easy to know when the other person has finished typing; one convention is to type o (for "over") when you want a response; type oo (for "over and out") when you're finished. The conversation goes on until one person types CTRL-C to actually break the connection.

Unfortunately, because there are several versions of talk, and because other things can go wrong, you may see other messages from the talk program. One common message is [Checking for invitation on caller's machine], which usually means that you won't be able to connect. If this happens, it's possible that one system has other versions of the talk program that will work with the particular system you're trying to connect to--try the ntalk program, for instance. It might also be easier to use a more flexible chat system, such as IRC.

6.7.2. IRC

IRC (Internet Relay Chat) is a long-established system for chatting with other users worldwide. IRC is fairly complex, with some rules you need to understand before using it. We give a brief introduction here; for more details, see http://www.irchelp.org.

6.7.2.1. Introducing IRC

Unlike the talk program, IRC programs let you talk with multiple users on multiple channels. Channels have names, usually starting with "#", such as #football. (You might hope that a channel name would tell you what sort of discussions happen there, but you'd often be wrong!) Many channels are shared between multiple servers on an IRC net, or network; you connect your IRC program to a nearby server, which spreads your channel to other servers around the net. Some channel names start with "&"; these channels are local to their server, and not shared around the net. Finally, you can meet a user from a channel and have a private conversation, a "DCC chat," that doesn't go through servers.

Each user on a channel has a nick, or nickname, which is up to 9 characters long. It's a good idea to choose a unique nick. Even when you do, if someone else with the same nick joins a channel before you do, you must choose another nick.

Two kinds of users are in control of each channel. Ops, or channel operators, choose which other users can join a channel (by "banning" some users from joining) and which users have to leave (by "kicking off" those users). If a channel is empty, the first user to join it is automatically the channel op. (As you can imagine, this system means that some ops can be arbitrary or unhelpful. If an op treats you badly, though, you can just go join another of the thousands of IRC channels.) IRC ops, on the other hand, are technical people in charge of the servers themselves; they don't get involved with "people issues."

IRC not only lets you chat; it lets you share files with other users. This can be helpful, but it also can be dangerous; see the Warning later in this section.

There are many IRC programs, or "clients," for different operating systems. They all work with each other, though some have more features. The best known Unix program is ircII, which you run by typing irc. Another well-liked program, based on ircII, is bitchx; get it from http://www.bitchx.org. Many programs can be modified by using scripts or bots; there are thousands of these floating around IRC. But we advise you to use only well-known programs, and to avoid scripts and bots, unless you know that they're safe.

IRC started long before graphical programs were popular. IRC programs use commands that start with a slash (/), such as /join #football or /whois StevieNix. Some IRC programs have buttons and menus that run commands without typing, but you'll probably find that learning the most common commands is easy--and makes chatting faster, overall, than using a mouse.

WARNING: IRC can be a wide open security hole if you don't use it carefully. If you type the wrong command or use an insecure program or script, any user can take over your account, delete all of your files, and more. Be careful!

IRC programs can be corrupted; scripts and bots can easily do damage. Even if you think that one is widely known and safe, it can contain a few lines of dangerous "trojan horse" code added by an unscrupulous user. Also, never type a command that another IRC user suggests unless you're sure you know what it does; /load and /dcc get can be especially dangerous.

Finally, you should know that IRC users can get information about you with the /whois nick command, where nick is your current nick. They'll see your real name unless you set the IRCNAME environment variable to another name (and log into your system again to make the change take effect). This is explained in Section 3.7, in Chapter 3. (By the way, use /whois with your nick to find out what other people can see about you.)

6.7.2.2. A sample IRC session

When you type irc, your terminal screen splits into two parts. The top part shows what's happening on the server and the channel; the bottom part (a single line) is where you type commands and text. In between the two parts is a status line with the time of day, your nick, and other information. Some terminals can't do what irc wants them to; if you get an error message about this, try the command irc -d to use "dumb mode" instead.

A good ircII command to start with is /help, which provides a list of other commands. The commands /help intro and /help newuser give introductions. For help with a particular command, give its name--such as /help server for help with the /server command. When you're done with help, you'll get a "Help?" prompt; you can type another help topic name, or simply press RETURN to leave the help system. Another common command is /motd, the "message of the day," which often explains the server's policies.

You can type your nick on the irc command line. Your IRC program should have a default server. You can change servers with the /server command; you'd do this if your server is full (you get the message "connection timed out," "connection refused," etc.). If your default IRC server is down or busy, you can also give a server hostname on the irc command line, after your nick.

In the following examples, we show the text you type (from the bottom line of the screen) in boldface, followed by the responses you might see (from the top of the screen) in unbolded text.

$ irc sstjohn us.undernet.org
*** Connecting to port 6667 of server us.undernet.org
	...
*** Closing Link: sstjohn by austin.tx.us.undernet.org (Sorry, your
+connection class is full - try again later or try another server)
*** Connecting to port 6667 of server us.undernet.org
	...
*** Welcome to the Internet Relay Network sstjohn (from
+Arlington.VA.US.Undernet.Org)
	...
*** on 1 ca 1(4) ft 10(10)

/motd
*** The message of the day was last changed: 27/7/2001
*** on 1 ca 1(4) ft 10(10)
*** - Arlington.VA.US.Undernet.Org Message of the Day - 
*** - 27/7/2001 20:39
	...
*** -         SERVER POLICIES:
	...

/help newuser
*** Help on newuser
	...
*** Hit any key for more, 'q' to quit ***
	...
Help? RETURN

/whois sstjohn
*** sstjohn is [email protected] (Steve St. John)
*** on irc via server *.undernet.org (The Undernet Underworld)
*** sstjohn has been idle 1 minutes

Messages from the server start with ***. Long lines are broken and continue on following lines that start with +. After connecting to the server, I used /whois with my nick to find what information other users could see about me. The Undernet servers have thousands of channels open, so I started by searching for channels with "help" in their names; you can use wildcards, such as *help*, to do this:

/list *help*
*** Channel    Users  Topic
*** #helpmania 2      A yellow light, an open door, hello neighbor,
+there's room for more. English
*** #underneth 14     -= UndernetHelp =- Ask your color free questions
+& wait for it to be answered. ([email protected])
*** #mIRCHelp  14     Welcome to Undernet's mIRC Help Channel! Beginners
+welcome :-)
*** #irc_help  48     Welcome to #irc_help. We do not assist in
+questions/channels regarding warez, mp3, porn, fserve, etc.
	...list goes on and on...

/list *mp3*
	...list of groups discussing/sharing MP3 files...

I want to see what's happening, so I join the biggest help channel: #irc_help, which has 48 users now:

/join #irc_help
*** sstjohn ([email protected]) has joined channel #irc_help
*** Topic for #irc_help: Welcome to #irc_help. We do not assist in
+questions/channels regarding warez, mp3, porn, fserve, etc.
*** Users on #irc_help: sstjohn ChuckieCheese Dodgerl GooberZ
+Kinger MotorMouth @theDRJoker MrBean SweetPea LavaBoy GrandapaJoe
	...

Some names in the list of users, like @Darkmind, start with @; these users are ops. Let's watch some more of the action. After a couple of users leave the channel, a new user MsTiger joins and asks for help. Each time a user types a line of text that isn't a command, it's sent to everyone else on the channel, preceded by that user's nick, like <MsTiger>:

*** ChuckieCheese has left channel #irc_help
*** GooberZ has left channel #irc_help
*** HelloWorld ([email protected]) has joined channel #irc_help
*** MsTiger ([email protected]) has joined channel #irc_help
<MsTiger> help me
<MsTiger> please
<Kinger> MsTiger what can we help you with ?
<MsTiger> my channel is not op 
<Kinger> LavaBoy tell MsTiger about no opers
<LavaBoy> MsTiger, *shrug*
<GrandapaJoe> MsTiger Sorry, but there are currently NO IRC Operators
+available to help you with your channels. Please be patient and wait
+for an Operator to join.
*** MsTiger has left channel #irc_help

The channel has gotten quiet, so I jump in with a question:

Hello all.  When I joined, I had a problem
    ...
Any suggestions??
*** Thor ([email protected]) has joined channel #irc_help
<[Wizard]> Can you help me plz
<LavaBoy> Try typing !help in the channel, [MORTAL].
/leave
*** sstjohn has left channel #irc_help
/quit
$

No one had an answer, so I left the channel after a few minutes of waiting. Other channels might be a lot livelier, and might have had someone willing to chat about my question, but I left the irc program by typing /quit. Then I got another shell prompt.



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.