You can do lots of things on a local UNIX system, but if you're lucky, your system is hooked up to the rest of the Internet world. UNIX offers some powerful tools to let you exploit your network connectivity.
The really fun part of UNIX, and one reason that it has grown dramatically, is that it's the most connected operating system in the world. The variety of services available for users of a networked UNIX machine is staggering. |
The Internet can help you with three main tasks: using remote systems, sending mail to remote users, and working with remote file systems. In addition, you can find out who is logged on to any system on the Internet with finger and use the talk program to talk with someone else.
If you know that the remote site is a UNIX system, the easiest way to log in to that site is to use the rlogin command, which has the awkward notation of rlogin host -l account. If you aren't sure about the remote operating system, use telnet, which is the universal program for connecting to remote computer systems. Unlike any of the other programs you've learned so far, telnet actually works either as a simple program you can invoke from the command line or as a sophisticated environment for connecting to various systems.
First off, I'll use rlogin to connect to a remote system and see whether I have a file there:
% rlogin intuitive.com Password:_
By default, rlogin assumes that your account on the remote system has the same name as your account on your home system. If you forget to use the -l account option, just press Return here, and it prompts for an account name:
% rlogin intuitive.com Password: Login incorrect login: taylor Password:_
Once I enter my password, I'm logged in to the remote system:
Last login: Mon Jun 29 15:27:24 from 204.247.39.239 Netcom On-line Communication Services, Inc. We thank you for your patience while we upgrade our network to better serve you. "" %
Using ls tells me what I want to know:
netcom % ls
Global.Software News/ history.usenet.Z
Interactive.Unix Src/ login
Mail/ bin/ testme
netcom %
The rlogin command offers a shorthand notation for logging out of the remote system; instead of using logout, you can simply enter ~. to do the job. To stop the rlogin session, use ~^z. No other tilde commands are available in rlogin.
I choose to log out the normal way:
netcom % logout
Connection closed
%
Now I'm back on the original computer system.
Just a quick note: telnet is a great way to learn more about UNIX if you're on a PC or Mac (as are the alternatives discussed in Hour 24, “Variations on the UNIX Theme”). All you need are a free telnet client, Internet access, and information from your ISP on what system to use. |
The alternative way to connect to a remote computer is to use telnet. The easiest way to use this command is the same way you use rlogin. At the command prompt, specify the name of the system to which you want to connect:
% telnet netcom.com
Trying...
Connected to netcom.com.
Escape character is '^]'.
SunOS UNIX (netcom)
login: _
Notice that this way is much more like having a terminal connected to this system. I can log in, enter my password, and then have a new login session on the remote system as if I were sitting in that computer room working away.
Instead, though, I'm going to use the ^] control character to switch back into the telnet program itself:
SunOS UNIX (netcom) login: ^] telnet > _
Now I enter help to see what the options are:
telnet> help
Commands may be abbreviated. Commands are:
close close current connection
display display operating parameters
mode try to enter line-by-line or character-at-a-time mode
open connect to a site
quit exit telnet
send transmit special characters ('send ?' for more)
set set operating parameters ('set ?' for more)
status print status information
toggle toggle operating parameters ('toggle ?' for more)
z suspend telnet
? print help information
telnet> _
There are lots of possible commands. I choose to return to my connection to Netcom, however; I just press Return, and I'm back at the login prompt. If I don't enter anything quickly enough, the remote system automatically drops the connection:
login: Login timed out after 60 seconds Connection closed by foreign host. %
To log out of the remote system, the best strategy is simply to exit the telnet session, which will drop the line automatically. If that doesn't work, the ^] sequence followed by either quit or close will do the trick.
To start out directly in the telnet command mode, simply enter the command without specifying a remote host:
% telnet
telnet> _
From here, connecting to the remote host is also quite simple:
telnet> open netcom.com
Trying...
Connected to netcom.com.
Escape character is '^]'.
SunOS UNIX (netcom)
login: _
Again, I use ^] and close to close the connection.
Both the rlogin and the telnet commands are useful in different situations, but I find myself using the rlogin command more often because it sends much of the current environment along to the remote system. So if I have my system set for a specific type of terminal (that is, the TERM variable is set to a specific value), that value is automatically copied into the new environment of the remote system, which saves lots of hassle. |
Many sites talk about having anonymous ftp capabilities. Systems allowing this connection indicate that you don't need your own computer account on that machine to be able to connect and copy files from their archives. To use these systems, enter ftp as the account name, and then enter your own email address as the password (for example, I'd enter ftp and then [email protected] as the password). The most important commands available in ftp are summarized in Table 20.1. The most important one to remember is bye, which you use when you're done.
To start out, I want to pick up a file from netcom that I saw earlier when I used rlogin to look at the remote system. To start ftp, I use the short notation of specifying the host at the command line:
% ftp netcom.com
Connected to netcom.com.
220 netcom FTP server (Version 2.1 Fri Apr 9 13:43 PDT 1996) ready.
Name (netcom.com:taylor): _
By default, ftp assumes that I want to use the same account name, which in this case I do, so I press Return and then enter my password:
Name (netcom.com:taylor): 331 Password required for taylor. Password: 230 User taylor logged in. ftp> _
Now I'm at the ftp program prompt, and any of the commands shown in Table 20.1 will work here. To start, I use dir and ls to list my files in different formats:
ftp> dir 200 PORT command successful. 150 Opening ASCII mode data connection for /bin/ls. total 140 -rwxr-xr-x 1 taylor users0 4941 Oct 4 1991 .Pnews.header -rw-r--r-- 1 taylor users0 2103 Sep 30 19:17 .article -rw-r--r-- 1 taylor users0 752 Apr 17 1998 .cshrc drwx------ 2 taylor daemon 4096 Dec 6 14:25 .elm -rw-r--r-- 1 taylor users0 28 Nov 5 09:50 .forward -rw-r--r-- 1 taylor users0 1237 Dec 13 09:40 .login -rw-r--r-- 1 taylor users0 6 Aug 6 1991 .logout -rw-r--r-- 1 taylor users0 538 Dec 6 14:32 .newsrc -rw-r--r-- 1 taylor users0 1610 Feb 17 1992 .plan -rw-r--r-- 1 taylor users0 0 Aug 6 1991 .pnewsexpert -rw-r--r-- 1 taylor users0 45 Feb 2 1993 .rnlast -rw-r--r-- 1 taylor users0 6 Feb 8 1993 .rnlock -rw-r--r-- 1 taylor users0 16767 Jan 27 1993 .rnsoft -rw-r--r-- 1 taylor users0 114 Apr 6 1998 .sig drwxr-xr-x 4 taylor users0 4096 Nov 13 11:09 .tin -rw-r--r-- 1 taylor users0 1861 Jun 2 1997 Global.Software -rw------- 1 taylor users0 22194 Oct 1 1995 Interactive.Unix drwx------ 4 taylor users0 4096 Nov 13 11:09 Mail drwxr-xr-x 2 taylor users0 4096 Nov 13 11:09 News drwxr-xr-x 2 taylor users0 4096 Nov 13 11:09 Src drwxr-xr-x 2 taylor users0 4096 Nov 13 11:09 bin -rw-r--r-- 1 taylor users0 12445 Sep 17 14:56 history.usenet.Z -rw-r--r-- 1 taylor users0 1237 Oct 18 20:55 login -rw-r--r-- 1 taylor users0 174 Nov 20 19:21 testme 226 Transfer complete. 1792 bytes received in 3.1 seconds (0.56 Kbytes/s) ftp> ls 200 PORT command successful. 150 Opening ASCII mode data connection for file list. Mail News bin Global.Software history.usenet.Z Src Interactive.Unix testme login 226 Transfer complete. 269 bytes received in 0.02 seconds (13 Kbytes/s) ftp>
As you can see, ftp can be long-winded.
Because you can supply some flags to the ls command, I always use -CF to force the output to list in multiple columns and show directories, which makes the output readable:
ftp> ls -CF
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
.Pnews.header* .newsrc Interactive.Unix
.accinfo* .oldnewsrc Mail//
.article .plan News/
.cshrc .pnewsexpert Src/
.delgroups .rnlast bin/
.elm/ .rnlock history.usenet.Z
.forward .rnsoft login
.ircmotd .sig testme
.login .tin/
.logout Global.Software
226 Transfer complete.
remote: -CF
287 bytes received in 0.05 seconds (5.6 Kbytes/s)
ftp>
One trick for using the ls command within ftp is that if you specify a set of command flags as a second word, it works fine. Specify a third argument, however, and it saves the output of the command into a local file by that name; so ls -l -C would create a file called -C on your system with the output of the ls -l command. |
To transfer the file login from the remote system, I can use the get command:
ftp> get (remote-file) login (local-file) login.netcom 200 PORT command successful. 150 Opening ASCII mode data connection for login (1237 bytes). 226 Transfer complete. local: login.netcom remote: login 1281 bytes received in 0.22 seconds (5.7 Kbytes/s) ftp>
Alternatively, I could use mget and specify a wildcard pattern similar to one I'd give the shell:
ftp> mget log* mget login? y 200 PORT command successful. 150 Opening ASCII mode data connection for login (1237 bytes). 226 Transfer complete. local: login remote: login 1281 bytes received in 0.03 seconds (42 Kbytes/s) ftp>
There was only one match, so the transfer was easy. Entering anything other than y at the mget login? prompt would have resulted in the file not being transferred.
That job was easily accomplished. Now I will look on another system in the anonymous FTP directory to see what's available.
To disconnect, I enter close so that I don't leave the ftp program:
ftp> close
221 Goodbye
ftp
There are hundreds of information servers on the Internet, offering an astounding variety of information, from weather service maps to the full text of the Bible and Alice in Wonderland to the source listings of thousands of programs.
In this example, I want to look at the anonymous FTP archive at the Massachusetts Institute of Technology's Artificial Intelligence Laboratory. The host is called ftp.ai.mit.edu:
ftp> open ftp.ai.mit.edu Connected to mini-wheats.ai.mit.edu. 220 mini-wheats FTP server (Version wu-2.4.2-academ[BETA-8](6) Thu Jan 25 07:08:03 EST 1996) Name (ftp.ai.mit.edu:taylor): ftp 331 Guest login ok, send your complete e-mail address as password. Password: 230- 230- 230-Welcome to the MIT Artificial Intelligence Laboratory. If you are 230-interested in Artificial Intelligence Laboratory publications please 230-ftp to publications.ai.mit.edu. 230- 230- 230- 230 Guest login ok, access restrictions apply. ftp>
Now I can use ls -CF to look around:
ftp> ls -CF
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
-rw-r--r-- 1 root daemon 171 Aug 25 1993 .message
drwxr-xr-x 2 bruce 114 512 Sep 1 1993 ai-pubs/
dr-xr-xr-x 2 root user 512 Jan 25 1996 bin/
drwxr-xr-x 2 root user 512 Mar 14 1995 dev/
dr-xr-xr-x 2 root user 512 Apr 24 1995 etc/
drwxrwxr-x 32 root user 512 Jul 28 12:55 incoming/
drwxr-xr-x 2 root wheel 8192 Mar 13 1995 lost+found/
lrwxrwxrwx 1 root daemon 9 May 10 1997 people -> pub/users/
drwxrwxr-x112 root user 2560 Sep 3 21:58 pub/
drwxr-xr-x 3 root staff 512 Apr 8 1992 usr/
226 Transfer complete.
58 bytes received in 0.39 seconds (0.15 Kbytes/s)
ftp>
It looks as though there might be something of interest in the pub directory (a directory by this name usually contains public information). I use cd to change to that directory, then dir to see what's available there:
ftp> cd pub 250 CWD command successful. ftp> dir 200 PORT command successful. 150 Opening ASCII mode data connection for /bin/ls. total 21407 drwxrwxr-x 2 bergenda user 512 Mar 20 1997 6.371 drwxrwxr-x 2 caroma user 512 Nov 25 1997 6.835 drwxrwxr-x 2 mdlm user 512 Sep 24 1995 DHC drwxrwxr-x 2 mdlm user 512 Aug 24 1993 GA drwxrwxr-x 2 loeb user 7168 Jun 11 1996 Kennedy lots and lots of lines drwxr-xr-x151 root user 2560 Oct 16 1997 users drwxrwxr-x 2 viola user 512 Sep 2 01:28 viola drwxrwxr-x 3 vkumar user 512 Aug 19 17:30 vkumar drwxrwxr-x 2 wang user 512 Jan 21 1997 wang drwxr-xr-x 3 wessler user 512 Aug 9 18:17 wessler drwxrwxr-x 5 ddaniel user 512 Jul 21 1994 x3j13 drwxr-xr-x 2 misha daemon 1536 Sep 24 1996 xemacs drwxrwxr-x 3 rst user 512 Feb 20 1995 xplay drwxrwxr-x 3 yip user 512 Dec 25 1997 yip drwxr-xr-x 2 yweiss user 512 Feb 6 1998 yweiss drwxr-sr-x 2 friedman user 512 Sep 11 07:01 zenirc ftp>
It's time to split and check another FTP archive, this time one at Apple Computer (ftp.apple.com):
ftp> close 221 Goodbye. ftp> open ftp.apple.com Connected to bric-a-brac.apple.com. 220 bric-a-brac.apple.com FTP server (IG Version 5.93 (from BU, from UUNET 5.51) Sun Nov 21 14:24:29 PST 1993) ready. Name (ftp.apple.com:taylor): ftp 331 Guest login ok, send ident as password. Password: 230 Guest login ok, access restrictions apply. ftp>
Again, ls -CF shows what files are available:
ftp> ls -CF
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
Apple_Support_Area/ dts/ research/
Quicktime/ etc/ web/
bin/ lib/ whymac/
devworld/ lists/
226 Transfer complete.
remote: -CF
143 bytes received in 0.01 seconds (14 Kbytes/s)
ftp>
I've been to this site before, and I know that a few directories down there are a lot of useful applications to help make a Macintosh friendlier for people with disabilities. Let's have a look by using the cd command to move:
ftp> cd /Apple_Support_Area/disability-solutions/shareware
250 CWD command successful.
You could use the DIR command to see what's in this directory, but I already know that there's a program called Snap To that I want to learn more about. I'll do a wildcard listing instead:
ftp> dir Snap*
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
-rw-r--r-- 1 0 system 30464 Mar 14 1998 Snap-To.sit.bin
-rw-r--r-- 1 0 system 1070 Mar 14 1998 Snap-To.txt
226 Transfer complete.
ftp>
Any file that has a filename suffix of .txt is usually a good thing to start with. A handy ftp trick is that you can copy files directly to your screen by using /dev/tty as the local filename, or you can even pipe them to programs by using the pipe symbol as the first character:
ftp> get Snap-To.txt |more
local: |more remote: Snap-To.txt
200 PORT command successful.
150 Opening BINARY mode data connection for Snap-To.txt (1070 bytes).
AUTHOR: Trevden Sherzell
NEEDS: Any Mac running System 6.0.4 or greater.
SYSTEM 7: Compatible
----------------
Keywords: DEFAULT BUTTON MOUSE SNAP TO CLICK ENTER RETURN DIALOG
Snap-To is a Control Panel that snaps the cursor to the default button
whenever a dialog comes up on your screen. Simple as that.
Snap-To will increase your speed when using a Macintosh, especially if
you use dialogs often and/or have a large screen.
Snap-To's features include:
* A Control Panel interface, which allows easy customization of several
of Snap-To's features.
* The ability for Snap-To to draw default button outlines around default
buttons which normally wouldn't have them.
* Optional automatic disabling in Open and/or Save dialogs.
* The ability for Snap-To to gradually move the cursor to the default
button, instead of abruptly snapping it there.
* The ability for Snap-To to move the cursor back to its original
location after you have closed a dialog box.
* Improved snapping over version 1.0.
* Full Balloon Help.
* And more!
ShareWare - $5.
226 Transfer complete.
1070 bytes received in 0.396 secs (2.6 Kbytes/sec)
ftp>
Sounds like a very interesting program, but not quite what I'm looking for, so let's move to another directory on this server.
A new Macintosh application is available on this system in dts/mac/hacks that I've been interested in seeing. I can move directly there with cd, confirming that I'm where I think I am with pwd:
ftp> cd /dts/mac/hacks 250 CWD command successful. ftp> pwd 257 "/dts/mac/hacks" is current directory. ftp> ls -CF 200 PORT command successful. 150 Opening ASCII mode data connection for /bin/ls. aetracker-3-0.hqx lockdisk-1-0.hqx applicon-2-1.hqx mountalias-1-0.hqx appmenu-3-5.hqx newswatcher.hqx bison-flex.hqx okey-dokey-1-0-1.hqx colorfinder.hqx oscar.hqx darkside-of-the-mac-4-2.hqx piston.hqx drop-disk-1-0b3.hqx snake.hqx dropper.hqx switchapp-1-1.hqx escape-dammit-0-4.hqx system-picker-1-0.hqx extensions-manager-2-0-1.hqx trashman-4-0-2.hqx flipper.hqx understudy.hqx folder-icon-maker-1-1.hqx unlockfolder.hqx fsid.hqx virtual-controllers.hqx im-mac-1-0b26w.hqx xferit-1-4.hqx 226 Transfer complete. remote: -CF 559 bytes received in 0.14 seconds (3.9 Kbytes/s) ftp>
I check to see how big the file is; then I can use get to transfer it, and drop the connection with bye:
ftp> dir colorfinder.hqx 200 PORT command successful. 150 Opening ASCII mode data connection for /bin/ls. -rw-r-xr-x 1 mjohnson archivis 43442 May 24 1991 colorfinder.hqx 226 Transfer complete. remote: colorfinder.hqx 71 bytes received in 0 seconds (0.069 Kbytes/s) ftp> get colorfinder.hqx 200 PORT command successful. 150 Opening BINARY data connection for colorfinder.hqx (43442 bytes). 226 Transfer complete. local: colorfinder.hqx remote: colorfinder.hqx 43442 bytes received in 2.09 seconds (20 Kbytes/s) ftp> bye 221 CUL8R. %
Now that I'm back at the command prompt, I can use ls again to confirm that I've received both the colorfinder.hqx and the login.netcom files:
% ls
Archives/ bin/ keylime.pie sample3
InfoWorld/ buckaroo login.netcom src/
Mail/ buckaroo.confused newsample src.listing
News/ cheryl papert.article temp/
OWL/ colorfinder.hqx sample tmp.listing
awkscript dickens.note sample2 who.is.who
%
The FTP system is a terrific way to obtain information from the Internet. Thousands of systems offer various services via anonymous FTP too: Table 20.2 lists a few of the most interesting ones. |
Site | Institution and Available Information |
---|---|
aisun1.ai.uga.edu | University of Georgia. Files: LISP, PROLOG, natural language processing, MS-DOS utilities. |
ftp.sfu.ca | San Francisco University. Files: MS-DOS, Mac. |
ftp.msu.edu | Michigan State University. Files: MS Windows. |
ftp.cs.rice.edu | Rice University. Files: Sun-Spots, Amiga, ispell, ofiles. |
ftp.cu.nih.gov | U.S. National Institutes of Health. |
deja-vu.aiss.uiuc.edu | University of Illinois Urbana-Champaign. Files: Rush Limbaugh transcripts, Monty Python, humor, song lyrics, movie scripts, urban legends. |
f.ms.uky.edu | University of Kentucky. Files: Mac, MS-DOS, UNIX, Amiga, NeXT, 386BSD, AppleII, GNU, RFCs, various Usenet archives. |
ftp.apple.com | Apple Computer. Files: Apple (Mac, II, IIgs) product information, software, developer support. |
ftp.cica.indiana.edu | Indiana University. Files: UNIX, MS-DOS, NeXT updates, MS Windows 3.x archive. |
ftp.csc.liv.ac.uk | Liverpool University Computer Science Department. Files: Ports to HP-UX machines (especially Series 700), including X11R4 clients, GNU, recreational software, text editors, system administrator tools. |
ftp.eff.org | Electronic Frontier Foundation. |
gatekeeper.dec.com | Digital Equipment Corporation, Palo Alto, California. Files: X11, recipes, cron, map, Modula-3. |
ftp.cs.caltech.edu | California Institute of Technology. Files: GNU (Free Software Foundation). |
info.umd.edu | University of Maryland. Files: government-related, books, economics, MS-DOS, Novell, Mac. |
ftp.ucsc.edu | University of California, Santa Cruz. Files: amoeba, U.S. Constitution. |
ftp.nsf.net | National Science Foundation Network. Files: Network information, Internet Resource Guide. |
ftp.sri.com | SRI International. Files: Improving the security of your UNIX system. |
anise.ee.cornell.edu | Cornell University. Files: tcsh. |
ftp.cc.columbia.edu | Columbia University. Files: kermit. |
There's no question that the interface to ftp is awkward, however; and there are a couple of programs that have tried to address this problem, as you learn in the next hour in this book.
There's no way here to fully cover all the information available on the Internet, so if you're excited by these possibilities, I strongly recommend that you obtain a copy of the book Navigating the Internet by Mark Gibbs and Richard Smith. It's a terrific introduction to the many services available on the Internet.