Some of the Internet’s great information resources are FTP sites, which contain hundreds of thousands of files from all over the Internet. FTP sites are similar to Web sites, but are directory-oriented and speak a different protocol. They’re less fun than the Web usually is but often more practical.
One of the easiest ways to access information on FTP sites is to use anonymous ftp, which lets you access the sites and download files to your computer (Code Listing 12.2, shown on the next page).
1. | ftp calvin.raycomm.com
At the shell prompt, type ftp followed by the name of the FTP site to which you’re connecting. Of course, if the computer has an IP number but no name, type the IP number instead. You’ll be prompted to log in, as shown in Code Listing 12.2. | |
2. | anonymous
For the user name, type anonymous. (Type ftp if you get tired of typing anonymous— it nearly always works.) | |
3. | [email protected]
Use your email address for the password. It’s polite to identify yourself to the people who provide the FTP service. Just you@ is usually sufficient. | |
4. | cd /pub/files
Use standard Unix cd commands to move through the directory tree to the file you want. Code Listing 12.2. Use anonymous ftp to get files from archives across the Internet.
| |
5. | binary
Specify the file type—in this case, binary, because we’re downloading a gzipped archive file. Specify ascii for README files, text, and HTML files. | |
6. | hash
Next, you have the option of typing hash to tell the ftp client to display a hash mark (#) for every 1, 024 bytes transferred. If you’re transferring a small file or using a fast connection, this might not be necessary; however, for large files and slow connections, the hash marks will let you know that you’re making progress. If you’ll be downloading multiple files, check out the sidebar Getting Multiple Files in this section before proceeding. The instructions for getting single and multiple files differ at this point in the process. | |
7. | get jokearchive.gz
At the ftp> prompt, type get and the filename to get the file from the remote system and plunk it into your own account. | |
8. |
✓ Tips
If the FTP connection seems to get stuck as soon as you log in, try -yourid@ wherever.com as the password. The character disables system announcements and helps keep your ftp client happy.
Some firewalls—particularly the ones on home networks—do not deal gracefully with some of the intricacies of the FTP protocol. If you can connect and log in, but not list files or get anything, the firewall might be the problem. As soon as you log in, type pass (for passive) and the problem should go away.
Another handy use for - is to view text files onscreen. For example, type get filename - to have the text just scroll by on the screen.
Instead of using get, use newer (as in newer goodjokes.gz) to get a more recent file with the same name as one you have.
If you start downloading a file and the FTP connection breaks, type reget and the filename to continue the transfer from wherever it left off. (You’ll have to reestablish the connection first, of course.)
You can tell the ftp client to make sure that all the transferred files have unique names by using runique instead of get. This way, you can ensure that files don’t overwrite existing files on your local system.
Use regular Unix commands like ls, pwd, and cd to move around in the remote system, and preface them with an ! to apply to your system. For example, cd .. would change to the next higher directory on the remote system, and !cd .. (from within the ftp client) would change to the next higher directory on the local system. The current local directory is where your files will be saved.
Getting Multiple FilesIf you’ll be getting multiple files with ftp, follow steps 1 through 6 in this section, then
|