FTP (File Transfer Protocol)


  
  1. Overview
  2. Basics: Concept and Getting around
  3. Learn Through Examples: a Complete anonymous FTP session for downloading files
  4. Important FTP Commands
    1. Different Types of File Format: "ASCII" and "Binary"
    2. Multiple File Transfers using "mget"
    3. Automatic Multiple File Transfers using "mget" & "prompt"
    4. Monitoring File Transfers using "hash"
    5. Uploading file(s) using FTP
    6. Summary of Frequently Used FTP commands
  5. FTP Mail
  6. Handling Binary Files through FTP Mail
  7. How do I stop the listings from scrolling off the screen?
  8. Where do I get anonymous FTP site listing?
  9. Problems with connecting a Site


  
Available CEE UCL softeware(s) related to this topic:

  • ftp (command-line mode)
  • ftptool (X11)



	





Overview

"The desire of knowledge, like the thirst of riches,
increases ever with the acquisition of it."
-- Laurence Sterne, Tristram Sandy

  
FTP is an abbreviation for File Transfer Protocol which allows a person to transfer files between two computers, generally connected via the Internet. Actually, it is probably more accurate to say that we will be using anonymous FTP.

Many computer systems throughout the Internet offer files through anonymous FTP. This means that you can access a machine without having to have an account on that machine (i.e. you don't have to be an official user of the system).

What sort of files are available through FTP? Well, "hundreds of systems connected to the Internet have file libraries, or archives, accessible to the public. Much of this consists of free or low-cost computer programs for virtually every make of computer. If you want a different communications program for your Wintel box, or feel like changing the window manager on your Linux, you'll probably be able to get it using FTP.

But there are also libraries of documents as well. If you want a copy of a recent U.S. Supreme Court decision, you can get a copy using FTP. Copies of historical documents, from the Magna Carta to the Declaration of Independence are also yours for the asking ... You can also find graphic images, song lyrics, poems, and even summaries of every X-files and Animaniacs episode ever made. (why...)

You can also find extensive files detailing everything you could possibly want to know about the Net itself. Also archives for electronic mailing lists are often stored on and are available through anonymous FTP. An enormous amount of information is stored on these machines and is ready for anyone who's seeking it.
Basics: Concept and Getting around
  
Before we get too in-depth into FTP, I think that now is as good a time to understand the client/server relationship.

"Client" is just another word for a program running on your system that enables you to talk to/get stuff from distant computers (called service provider or your "Server" in short, for example; UCL's network server, AOL, etc.) The client on your system takes your commands and translates them into requests for information understood by distant computers.

The client/server relationship allows you to Telnet into remote computers and run programs on those remote computers, and it also allows you to use FTP to get files from remote sites. While all of the FTP clients out there do the exact same thing, they all use different commands to do it.

Fortunately, if you can understand the basics of what happens during an FTP session, the commands -- no matter what client you are using -- are pretty easy and the same.

The basic steps in an FTP session are:

  1. Start-up your FTP client
  2. Give your FTP client an address to connect to
    (step one and two can be combined into one easy step)
  3. Identify yourself to the remote site
  4. Give the remote site your password
  5. Look around the directory for files
  6. Change Directories
  7. Set the transfer mode (optional)
  8. Get the file(s) you want
  9. Quit
Learn Through an Example: a FTP session
  
"The quickest way to a man's heart is through his chest, with an axe"
-- Unknown

The best way to understand what is going on is to look at a sample FTP session. MIT maintains an anonymous FTP server (rtfm.mit.edu), and in this particular server, there is whole bunch of up-to-date FAQs (Frequently Asked Questions) on almost everything you can imagine under "/pub/usenet/news.answers" subdirectory, so I'm going to FTP to it.

Starting an FTP session is pretty easy. For most of you, all you have to do to start-up your FTP client is type

bash:[sparky] ~>ftp

on you system's command prompt (or, if you are in a Windows or Mac environment, double-click on the FTP icon). Like Telnet, however, there is a way to combine these two steps into one, easy step. For most of you, to access your FTP client and give your client an address to hook up to, all you would have to do it type the command
ftp <site address>

and replace <site address> with the address of the FTP site that you want your client software to access.

In our example, MIT's FTP address is rtfm.mit.edu, so I would type
bash:[sparky] ~>ftp rtfm.mit.edu

to start an FTP session. Once I hit the enter key, the following appears on my screen:
bash:[sparky] ~> ftp rtfm.mit.edu
Connected to PENGUIN-LUST.MIT.EDU.
220 rtfm ftpd (wu-2.4(67) with built-in ls); bugs to ftp-bugs@rtfm.mit.edu
Name (rtfm.mit.edu:yoon):

The second line tells me that my system is connecting to rtfm.mit.edu, the third line is some automatic information from rtfm.mit.edu, and the bottom line is asking me to log in. If I had an account on the rtfm.mit.edu system, I would enter my rtfm.mit.edu's user ID. But, since I don't have an account on this system, I have to find another way to access the system. ;)

This is where the "anonymous" FTP I mentioned earlier comes in. The other way to access some FTP sites -- at least those FTP sites that allow outside access -- is to use the userid "anonymous". By using the name "anonymous", you are telling that FTP site that you aren't a regular user of that site, but you would still like to access that FTP site, look around, and retrieve files.

So, where it says Name, I type the word
anonymous

hit enter, and cross my fingers. If MIT ftp server does not allow anonymous access, I'm about to find out.
Name (rtfm.mit.edu:yoon): anonymous
331 Guest login ok, send your complete e-mail address as password.
Password:

Good, it's going to let me in. All I have to do is give the site a password. Out of politeness to the FTP site, if you login as "anonymous", you need to use your full Internet address as your password. This helps the FTP site keep track of who has visited its site. So, since it wants my password, and since the password for any anonymous FTP session is my full Internet address, I type
yoon@Old_Dominion_U.edu

Once I hit enter, my screen fills with the following:
230 Guest login ok, access restrictions apply.
ftp>

Notice the line "Guest login ok, access restrictions apply." This means that the site has given me access, but I only have access to the files that are available to the general public.

Keep in mind that NEVER TYPE A PASSWORD THAT YOU USE ON YOUR OWN SYSTEM when you're accessing an anonymous FTP server. (Each anonymous connection is logged with user name and password)

Okay ... now what? I've started-up my FTP client, I've given the client an FTP address to connect to, I've identified myself to the remote site (I told it that I am anonymous), and I've given the site my password.

Now it's time to see what sort of files and directories are around, and to get those files. (BTW, you can see a list of all of the acceptable commands for your FTP client by typing "help" or "?")

On most FTP clients, the command to list the contents of the current directory on the remote machine is just dir. (Of course, if you're using a GUI-based FTP client, current directory listing will be automatically displayed)

My FTP client accepts and uses the "dir" command, so I type
ftp> dir

(use Control-H to 'basckspace' or 'Del' in case of mistyping) and the following appears on my screen:

ftp> dir
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.

total 8512
-rw-r--r--   1 root     daemon          0 Feb  3  1998 .k5login
-rw-r--r--   1 root     daemon          0 Jul 29  1996 .klogin
-rw-r--r--   1 root     daemon          0 Apr 14  1993 .notar
-rw-r--r--   1 root     daemon    3443891 Jan 27 08:15 Index-byname
-rw-r--r--   1 root     daemon     483709 Jan 27 08:15 Index-byname.gz
-rw-r--r--   1 root     daemon    3443891 Jan 27 08:15 Index-bytime
-rw-r--r--   1 root     daemon     302454 Jan 27 08:16 Index-bytime.gz
-rw-r--r--   1 root     daemon        249 Feb  3  1998 Index.README
drwxr-x--x   3 root     daemon        512 Feb  3  1998 bin
drwxr-x--x   2 root     daemon        512 Mar 21  1998 dev
drwxr-x--x   4 root     daemon        512 Feb  3  1998 etc
drwxr-xr-x   3 root     70            512 Jan 26  1998 installkits
-rw-r--r--   1 root     daemon     974409 Jan 27 08:27 ls-lR.Z
drwxrwxr-x  36 root     system       1536 Aug 30 02:19 pub
drwxr-x--x   4 root     daemon        512 Oct  5  1994 usr

226 Transfer complete.
987 bytes received in 0.095 seconds (10 Kbytes/s)
ftp>

This is a listing of all of the stuff in the current directory. Let's take a look at the first entry and see if we can figure out what all of this means:


drwxr-x--x   3 root     daemon        512 Feb  3  1998 bin

If the line begins with a "-" instead of a "d", it is a file. The letter "d" at the beginning of this example tells me that this is not a file -- it is a subdirectory.

What does THAT mean? Well, pretend that the FTP site is simply a big house. You walk into the house through the front door, and you find yourself standing in an entry hall. The entry hall may have some neat stuff in it, but it also has doors leading to other rooms throughout the house. The subdirectories (the "d"s) are just doors to other "rooms" at the FTP site, and the files (the "-"s) are the neat stuff that you can get while you are at the site.

Getting back to our example,


drwxr-x--x   3 root     daemon        512 Feb  3  1998 bin

the "drwxr-x--x" tells us that this entry is a subdirectory (the "rwxr-x--x" part is called a file permission, and it contols the ownership of this subdirectory, and who can access it). The "512" tells us the size of the subdirectory in bytes. The "Feb 3 1998" tells us the date and time that this subdirectory was last updated. The last part (the "bin") tells us the name of the subdirectory.

Let's look at one more example:


-rw-r--r--   1 root     daemon    3443891 Jan 27 08:15 Index-byname

There is a "-" instead of a "d", so this is a file. The "3443891" tells us that the size of this file is 3,443,891 bytes (or about 3.36 Megabytes), the file was last updated on Jan 27 08:15 of current year, and the name of this file is "Index-byname".

Let's get back to the main directory contents:

total 8512
-rw-r--r--   1 root     daemon          0 Feb  3  1998 .k5login
-rw-r--r--   1 root     daemon          0 Jul 29  1996 .klogin
-rw-r--r--   1 root     daemon          0 Apr 14  1993 .notar
-rw-r--r--   1 root     daemon    3443891 Jan 27 08:15 Index-byname
-rw-r--r--   1 root     daemon     483709 Jan 27 08:15 Index-byname.gz
-rw-r--r--   1 root     daemon    3443891 Jan 27 08:15 Index-bytime
-rw-r--r--   1 root     daemon     302454 Jan 27 08:16 Index-bytime.gz
-rw-r--r--   1 root     daemon        249 Feb  3  1998 Index.README
drwxr-x--x   3 root     daemon        512 Feb  3  1998 bin
drwxr-x--x   2 root     daemon        512 Mar 21  1998 dev
drwxr-x--x   4 root     daemon        512 Feb  3  1998 etc
drwxr-xr-x   3 root     70            512 Jan 26  1998 installkits
-rw-r--r--   1 root     daemon     974409 Jan 27 08:27 ls-lR.Z
drwxrwxr-x  36 root     system       1536 Aug 30 02:19 pub
drwxr-x--x   4 root     daemon        512 Oct  5  1994 usr

I want to change this main directory and get into a subdirectory. To change directories on most FTP clients, you use the command cd <directory> and replace <directory> with the name of the directory that you want to access.

Since I am interested in public information, I'm going to get into "pub" directory ("pub" is the standard FTP abbreviation for "public"). I type
ftp> cd PUB

and the following appears on my screen:
ftp> cd PUB
550 PUB: No such file or directory.
ftp>

hmmmm ... what happened? Ah, it's the case of the "PUB!" Most of FTP servers are Unix machines, and Unix is by its virtue case sensitive. :=) My cd PUB command did not work because there is no PUB directory ... but there IS a pub directory. Let's try it again. I type then
ftp> cd pub

and the following appears on my screen:
ftp> cd pub
250 CWD command successful.
ftp>

Good! It worked! Now I need to see the contents of this new directory that I just entered. Do you remember what FTP command was used to list the current directory?

Then, I type dir, and the following appears on my screen:

ftp> dir
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.

total 2554
-rw-r--r--   1 3382     395         99943 May 23  1990 MAP.PS
drwxr-xr-x   2 3382     395           512 May 30  1993 MulticsMap
-rw-r--r--   1 3382     15010          67 Sep 17  1988 WorldMap.notes
-rw-r--r--   1 3382     395         75351 Jun 23  1989 WorldMap.rsalz.shar
-rw-r--r--   1 3382     15010     1585725 Sep 17  1988 WorldMap.tar.Z
-r--r--r--   1 root     15010        8139 Oct  3  1986 arpaprob.txt
drwxrwxr-x   2 16256    system        512 Oct 31  1996 bert
-rw-r--r--   1 8973     15010      106496 Dec  9  1986 brunhoff_doc.tar
drwxrwxr-x   2 8973     system        512 Feb 23  1996 cc-vc
drwxrwxr-x   2 root     system        512 Mar  3  1994 cdmm
-rw-r--r--   1 3382     15010       37807 May  4  1988 chess.ps
drwxrwxr-x   2 3009     system        512 Feb 23  1995 com_err
drwxr-xr-x   2 9978     system        512 Aug 28  1994 compression_apps

	*
	*
	*

lrwxrwxrwx   1 root     system         15 Feb  5  1998 usenet -> usenet-by-group
drwxr-xr-x   2 root     system        512 Jul 14  1996 usenet-addresses
drwxrwxr-x 2288 3009     3           68096 Jan 28 00:44 usenet-by-group
drwxrwxr-x 126 root     3            2048 Jan  2 00:38 usenet-by-hierarchy
drwxrwxr-x   2 9661     system        512 Nov 27  1996 warlord
drwxr-xr-x   2 7783     15010         512 Jul 20  1998 whois
drwxrwxr-x   3 root     system        512 Nov 30  1993 wipe
-rw-r--r--   1 3382     15010       34721 Apr  1  1988 x11_release
-rw-r--r--   1 357      15010        5182 Jan 28  1987 x2ps.c
-rw-r--r--   1 15864    395         63381 Apr 19  1990 xbugchess.tar.Z
drwxrwxr-x   3 3009     system        512 Dec 28 13:19 xrn
drwxrwxr-x   2 root     system        512 Sep  7  1993 xscreensaver
drwxr-xr-x   4 3382     395           512 Dec 18  1997 z80

226 Transfer complete.
4025 bytes received in 0.15 seconds (26 Kbytes/s)
ftp>

Since I want to know what kind of FAQs are currently available, I will change to "/pub/usenet/news.answers" subdirectory. I type

ftp> cd usenet/news.answers

250-| COPYRIGHT NOTICE
250-| ~~~~~~~~~~~~~~~~
250-| Nearly all of the files contained in this directory are copyrighted
250-| by their respective maintainers.  (Even files without explicit
250-| copyright notices are copyrighted under the international Berne
250-| Convention, in effect in most countries.)  Some of the files,
250-| although certainly not all, prohibit redistribution for any
250-| commercial purposes without prior approval; other kinds of
250-| restrictions may also be imposed by the maintainers.
250-|
250-| Approval for use when there are restrictions imposed must be
250-| obtained from the maintainers of each file, *NOT* from the
250-| maintainers of this archive.  If you have any doubts about whether
250-| you may redistribute a particular file for some particular purpose,
250-| contact its author.
250-|
250-| Making a copy for your own personal reading is implicitly allowed.
250-

226 Transfer complete.
ftp>

After changed to "/pub/usenet/news.answers", I'd like to make it sure I'm in the right place. To find where you are, you can use pwd command which shows the "present working directory (=pwd)" on the remote computer.
ftp> pwd
257 "/pub/usenet-by-group/news.answers" is currnt directory
ftp>

Very well, I'm in the right place. Now I need to see the contents of this new directory that I just entered. Do you remember what FTP command I should use to list the current directory?

ftp> dir
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.

total 9228
drwxrwxr-x 417 3009     3           12288 Jan 27 06:05 .
-rw-rw-r--   1 8027     3          434848 Jan 26 08:53 .#index
drwxrwxr-x 2288 3009     3           68096 Jan 28 00:44 ..
-rw-r--r--   1 28252    3             639 Jul 17  1995 .message
drwxrwxr-x   2 root     3             512 Oct 14  1997 386bsd-faq
drwxrwxr-x   2 root     3             512 Jul 25  1998 3b1-faq
-rw-rw-r--  10 99       3            3019 Nov 10  1997 3d-programmer-info
drwxrwxr-x   3 root     3             512 Jul 24  1995 AOL
drwxrwxr-x   2 root     3             512 Jan  8 00:06 AudioFAQ
drwxrwxr-x   4 root     3             512 Sep 16  1997 C++-faq
drwxrwxr-x   2 3009     3             512 Jan 15 11:35 C-faq
drwxrwxr-x   3 root     3             512 Apr 15  1997 CAD
-rw-rw-r--   6 99       3           80571 Jan 21 06:04 CPM-faq
drwxrwxr-x   2 root     3             512 Jan 16 01:43 GNU-Emacs-FAQ
drwxrwxr-x   2 root     3             512 Jan 25 00:28 LANs
-rw-rw-r--  10 99       3           53147 Jan 26 00:52 LEGO-faq
-rw-rw-r--   6 99       3           59345 Jan 20 00:47 Modula-3-faq
-rw-rw-r--   8 99       3          240539 Apr 11  1998 NeXT-FAQ
drwxrwxr-x   2 root     3             512 Sep 18 00:38 Objective-C
	
	*
	*
	*
	
-rw-rw-r--   6 99       3           68530 Dec 31 00:46 whitewater-addr
drwxrwxr-x   7 root     3             512 Jun  7  1998 windows
drwxrwxr-x   2 root     3             512 Nov 30 00:50 windows-emulation
drwxrwxr-x   3 root     3             512 Jan  1  1995 windows-nt
drwxrwxr-x   2 root     3             512 Jun 28  1998 wine-faq
-rw-rw-r--   4 root     3           27598 Apr 18  1995 wireless-cable
drwxrwxr-x   4 root     3             512 Oct 12 00:13 woodworking
-rw-rw-r--   6 99       3           41234 Jan 25 00:25 world-war-2-faq
drwxrwxr-x   4 root     3             512 Jan 26 00:52 writing
drwxrwxr-x   5 root     3             512 Jan 26 09:02 www
drwxrwxr-x   2 root     3             512 Jan  9 00:50 x-faq
-rw-rw-r--   6 99       3           20909 Jul 30  1997 xanadu-faq
drwxrwxr-x   3 root     3             512 Oct  9  1995 yolo
-rw-rw-r--   8 99       3           24204 Nov  1 00:42 z-faq
drwxrwxr-x   2 root     3             512 Jan 25 00:28 zoroastrianism

226 Transfer complete.
37160 bytes received in 0.23 seconds (32 Kbytes/s)
ftp>

Hmm..., that was a long listing. That first file, .#index, looks what I'm looking for. I bet it contains some important information and list of FAQs that will make my life a whole bunch easier (Good rule of thumb: if you see a file that contains the words INDEX or README, it is an important file). I need to get this .#index file.

To get a file using FTP, you use the get <filename> command, replacing <filename> with the name of the file that you want to get. The get command retrieves the file from the remote site and stores the file on your service provider's system. Since the filename .#index starts with ".," I want to save .#index file with different name on my computer. To do that, use
ftp> get <filename> <name I want it saved as>

command, replacing "<remote file name>" with ".#index," and replacing <name I want it saved as> with the name that I want the file to be saved as on my computer. So, I type
ftp> get .#index faq_index

and the following appears on my screen:
ftp> get .#index faq_index
200 PORT command successful
. 150 Opening ASCII mode data connection for .#index (434848 bytes).
226 Transfer complete.
local: faq.index remote: .#index
441351 bytes received in 3.3 seconds (1.3e+02 Kbytes/s)
ftp>

Great, it worked! Now, to end a FTP session, you need to use either the "quit" or "bye" commands. On my client, the command is "quit", so I type
ftp> quit
221 Goodbye.

and I'm back to my Unix system prompt.
bash:[sparky] ~>

Okay. I got the file. Looking at this new file that I just got from FTP, I discover that the contents of the ".#index" file are a brief explanation of what is in every subdirectory off of the "/pub/usenet/news.answers" directory:
   386bsd-faq/part1  [comp.unix.bsd] NetBSD, FreeBSD, and 
   OpenBSD FAQ (Part 1 of 10)
   comp.unix.bsd.netbsd.announce,comp.unix.bsd.freebsd. . . 

   386bsd-faq/part10  [comp.unix.bsd] NetBSD, FreeBSD, and 
   OpenBSD FAQ (Part 10 of 10)
   comp.unix.bsd.netbsd.announce,comp.unix.bsd.freebsd. . . 

   386bsd-faq/part2  [comp.unix.bsd] NetBSD, FreeBSD, and 
   OpenBSD FAQ (Part 2 of 10)
   comp.unix.bsd.netbsd.announce,comp.unix.bsd.freebsd. . . 

   386bsd-faq/part3  [comp.unix.bsd] NetBSD, FreeBSD, and 
   OpenBSD FAQ (Part 3 of 10)
   comp.unix.bsd.netbsd.announce,comp.unix.bsd.freebsd. . . 

   386bsd-faq/part4  [comp.unix.bsd] NetBSD, FreeBSD, and 
   OpenBSD FAQ (Part 4 of 10)
   *
   *
   *

   ftp-list/faq   Anonymous FTP: Frequently Asked Questions 
   (FAQ) List
   news.newusers.questions,news.announce.newusers,alt.sources. . . 

   *
   *
   *
I want to go back and get "Anonymous FTP: Frequently Asked Questions (FAQ) List" in the MIT anonymous FTP server (rtfm.mit.edu). Thanks to what I found from the .#index file, I now know that the files that I am looking for are in "/pub/usenet/news.answers" directory and in the "ftp-list" subdirectory with file name "faq". In FTP notation, I can write this as
/pub/usenet/news.answers/ftp-list

This means the same thing as saying "in the pub directory, in the usenet subdirectory, in the news.answers subdirectory, in the ftp-list subdirectory" and, as you will soon see, this notation will eventually even save me a few steps.

Let's go back to MIT anonymous FTP server (rtfm.mit.edu) and get some newsletter articles!

I type

bash:[sparky] ~>ftp rtfm.mit.edu
Connected to PENGUIN-LUST.MIT.EDU.
220 rtfm ftpd (wu-2.4(67) with built-in ls); bugs to ftp-bugs@rtfm.mit.edu.
Name (rtfm.mit.edu:yoon): anonymous
331 Guest login ok, send your complete e-mail address as password.
Password:
230 Guest login ok, access restrictions apply.
ftp>

I know that I want to get into the pub directory, and then into the usenet subdirectory, then in the news.answers subdirectory, then in the ftp-list subdirectory. I could type "cd pub" and then "cd usenet" and then "cd news.answers" and then "ftp-list" to get into the subdirectory that I want, but it would be easier to just jump into the "ftp-list" directory with one command.

I can make such a jump using the "cd /pub/usenet/news.answers/ftp-list" all at once.
ftp> cd /pub/usenet/news.answers/ftp-list
250 CWD command successful.
ftp>

Since I have no idea what is in the "ftp-list" subdirectory that I just entered, I type
ftp> dir

and the following appears on my screen:

ftp> dir
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.

total 62
-rw-rw-r--  18 99       3           61915 Nov 14  1997 faq
drwxrwxr-x   2 root     3             512 Nov 14  1997 sitelist

226 Transfer complete.
135 bytes received in 0.019 seconds (6.8 Kbytes/s)
ftp>

Very well, let's get the faq. Since I want the file "faq" and save it as "ftp.faq" in my Unix account, I type

ftp> get faq ftp.faq

and the following appears on my screen:

ftp> get faq ftp.faq
200 PORT command successful.
150 Opening ASCII mode data connection for faq (61915 bytes).
226 Transfer complete.
local: ftp.faq remote: faq
63321 bytes received in 0.5 seconds (1.2e+02 Kbytes/s)
ftp>

I then quit FTP by typing either "quit" or "bye", and I can open the file "ftp-faq" and learn all about FTP.
Different Types of File Format: ASCII and Binary
  
Okido, I showed you how to retrieve a text file using FTP. But how can a text file written on an Apple Macintosh be read on a Windows or on a Unix workstation? This is all possible to something called "ASCII". ASCII is an abbreviation for American Standard Code for Information Interchange, and it is the standard format for transmitting textual data. Any computer or OS can read an ASCII text file. Without going too in-depth into how ASCII works, let's just say that ASCII ensures that the text in an ASCII text file will appear the same on any computer regardless of the computer's brand name or operating system.

ASCII is fine and dandy for saving and transferring text files, but it won't work with non-text, data files like computer programs. Data files must be saved in "Binary" (which consists of a bunch of zeros and ones). Binary files are files that can only run on certain machines or programs. Good examples of Binary files include shareware software (either *.exe or *.zip format), Microsoft Word files, satellite weather images, and sound files.

Remember, ASCII files are just 'plain' text files that can be read on any computer, and Binary files are files that can only be run on certain computers or programs that Binary files were created.

Unfortunately, there is no universal default transfer mode for FTP clients. Some clients use ASCII as the default, and others use binary. This means that unless you tell your FTP client to do otherwise, all of your files will be transferred in the default transfer mode.

If your client's default transfer mode is ASCII and you try to retrieve a Binary file without first resetting the transfer mode, your Binary file will be transferred in ASCII and the file *WILL NOT WORK* even the file transfer was successful. Fortunately, changing the transfer mode in FTP is easy. All that most of you have to do to change the FTP transfer mode from ASCII to Binary is type

ftp> binary

right before you get the file, and the file will be transferred to you in Binary format. To change back to ASCII transfer mode, just type

ftp> ascii

and FTP will reset its transfer mode to ASCII.

If you ever forget what transfer mode you are currently using -- something that I do *ALL* of the time -- all you need to do is type

ftp> status

and your computer will display a whole bunch of information, including your transfer mode.

BTW, how can you tell if a file is an ASCII file or a Binary file? Well, take a look at the file extensions. If the file's extension is .doc or .txt, or if the file does not have an extension, it is a good bet that the file is an ASCII text file. If the file has an extension -- like .exe or .zip or .gz -- it is a good bet that the file is a Binary file. There are, of course, always exceptions to this rule.

The "duck theory" also works pretty well in determining if a file is an ASCII or Binary file. The duck theory says that if it looks like a duck, waddles like a duck, swims like a duck, quacks like a duck, and is seen hanging around with other ducks ... it is probably a duck.

Using the duck theory to determine if a file is an ASCII or Binary file, you can safely assume that if you have a file that looks like a ASCII text file and is seen in the same directory as other ASCII text files, you can safely assume that the file that you are looking at is, in reality, a DUCK :)

To tell the truth, the easist and care-free way of FTPing files, especially you're not quite for sure (or care less) about format of file -- either ASCII or Binary, is just use Binary mode. An ASCII file FTPed using Binary mode will be still ASCII format, but it takes a little bit more time to download.
Multiple File Transfers using mget
  
How can you transfer multiple files at the same time? For example, you may have seven files to download, and simply don't like the idea of typing every single file name repeatedly. In such case, use the "mget" (multiple get) command.

Let's say that I want to get every file in a particular directory that starts with the word "duck" in their file names. (i.e., 'duck001.txt,' 'duck002.exe,' 'duck_dll.zip,' and so forth)

I would type

ftp> mget duck*

The '*' is a "wild card" that tells the client to get every file that begins with the word "duck" and that has any additional characters after the word "duck."

The best way to explain wildcards is to give you an example. Let's pretend that I have a directory with the following files in it:
	duckreport.doc	ducket.exe
	ducket.tar.gz	duck1.txt
	duck2.txt		ducksoup
	duck.jpg
Depending on where I place the wildcard in mget command, I will I get:

mget command Files it would retrieve
mget duck* duckreport.doc
ducket.exe
ducket.tar.gz
duck1.txt
duck2.txt
ducksoup
duck.jpg
mget duck*.txt duck1.txt
duck2.txt
mget duck.* duck.jpg
Automatic Multiple File Transfers using mget and prompt
  
When you "mget" multiple files, the FTP client on your system will ask you whether you want to download each file or not. You can answer to it by type "y<es>" at its prompt, or simply press <return> key to confirm. But, in case you're downloading many files, let's say 20+, using "mget", then, this faithful confirmation prompt process starts irritating.

For such case, you can use "prompt" command to suppress confirmation prompt. "prompt" command is a toggle-type command, which is either "turned on" or "turned off". Normally default "prompt" mode is off (so that confirmation is required for each file). By typing "prompt", you can turn off confirmation prompt for "mget".

ftp> prompt
ftp> "prompt" is now turned off
ftp>

Once turned off, all files matched "mget" wild card (=*) string will downloaded automatically without prompting download confirmation. You can toggle it on by typing "prompt" at the ftp prompt again.
ftp> prompt
ftp> "prompt" is now turned on
ftp>

For more information, check the FTP 'help' function for your client program.



Monitoring File Transfers using hash
  
Imagine you're FTPing to a remote computer, and able to locate the file you're looking for. After checking the size of a file, let's say 500,000-byte (or about 488.3 KB since 1 KB = 1024 bytes), you start downloading the file. The FTP prompt says the file is downloading, but you can't see any visible sign of downloading activity or anything. After staring the screen over 2 minutes without a blink, you're getting impatient and really wondering 'is there anything going on there?' Sounds familiar?

Well, there is one FTP command called "hash". what it does is that it puts a '#' on the screen for every <number> of bytes transferred. <number> is 1024 in some cases, 2048 in others but is between 1024 and 4096 in most cases. Thus give you a peace of mind...

"hash" command is a toggle-type command like "prompt", which is either "turned on" or "turned off". Normally default "hash" mode is off (so that nothing will be showed on during the download). By typing "hash", you can turn on '#'- hash mark for "get" and "mget".
ftp> hash
ftp> "hash" is now turned on
ftp>

You can toggle it on by typing "hash" at the ftp prompt again.
ftp> hash
ftp> "hash" is now turned off
ftp>

For more information, check the FTP 'help' function for your client program.

Uploading file(s) using FTP
  
You can upload a file(s) to a FTP server - which could be either anonymous FTP server and/or a regular network FTP server in your own network. The procedure for uploading file(s) is exactly the same as downloading.

The only differences are:

  • You can use your e-mail address as your password if you're uploading file(s) to an anonymous FTP server that allows and has a designated directory for uploading (usually directory named as either "uploads" or "incoming"). Make it sure you check in advance with the remote FTP server administrator for uploadability.

  • If you're uploading (or more accurately, 'internally transferring') file(s) within you're own network system, use your own regular password to log in to your system's FTP server.

  • To upload file(s), use "put" command instead of "get" command. Of course, you can use "mput" command in junction with "hash" and/or "prompt".

For more information, RTFM for FTP.
Summary of Frequently Used FTP Commands
  
All the normal FTP commands may be used to retrieve files. Some FTP commands are the same on different computers, but others are not. Also, some of the FTP sites offer custom commands like getting a directory with one command or searching of directories. Read the relevant README files on the site itself for the 'special access features'.

Usually, during a FTP session, you can get a list of commands if you type "help" or type a "?" at 'ftp>' prompt . Also, you can get a more detailed information about FTP by reading man pages on FTP.

Some useful commands available on most systems include:

FTP command It does
ascii Switch to ascii mode. Ascii mode is the default mode and used for transferring text files.
binary Switch to binary mode. For transferring binary files like .tar.gz or .exe files.
cd Change the directory on the remote(=server) computer.
dir List the files in the current directory on the remote computer.
ls
(or 'ls -al')
Same as 'dir'.
get Copy/Download a file from the remote computer (=server) to yours (=client).
hash Visual aid for transfer status. Puts a '#' on the screen for every of bytes transferred. is 1024 in some cases, 2048 in others but is between 1024 and 4096 in most cases.
help Gives help on the use of commands within the ftp program
lcd Change the directory on your computer (the 'l' is for local) without quit/restart the ftp session. By default, all file will be downloaded to/uploaded from the current directory where you started the FTP session.
lpwd Shows the present working directory (pwd) on your computer (the 'l' is for local). Note: this may not work on all machines. On a Unix machine, try !pwd if lwpd doesn't work.
mget Copy/Download multiple files from the remote computer (=server) to yours (=client).
mput Copy/Upload multiple files from the your computer (=client) to a remote computer (=server) only if the remote computer allows uploading or you have a user account in the remote computer.
prompt Turn on/off the prompt for file fransfer confirmation.
pwd Shows the present working directory (pwd) on the remote computer (=server)
put Copy/Upload a file from the your computer (=client) to a remote computer (=server) only if the remote computer allows uploading or you have a user account in the remote computer.
FTP Mail
  

"The whole of science is nothing more than
a refinement of everyday thinking."
-- Albert Einstein, Out of My Later Years

If your system or local Internet service provider does not have an FTP client, you can still get FTP files by using a tool called FTPmail. However, current proliferation of world wide web makes this FTPmail method almost obsolete. But, as always, you never know.

The steps in a basic FTPmail session are pretty easy:

  1. Write an e-mail letter to an FTPmail server near you, and put the necessary FTPmail commands in the BODY of your letter.

  2. The FTPmail site will write you back and tell you that it has received your request, and will tell you the number of requests ahead of yours.

  3. A day or two later -- yes, I said "day" -- the FTPmail system will e-mail you the file that you requested. The FTPmail system will also send you a copy of the "transaction" as it occurred between FTPmail and the remote FTP site (this transaction will look a lot like the example that we went through).

Well, I am going to show you how to get ASCII text files using FTPmail. The first step is finding an FTPmail site near you. FTPmail was developed at the Digital Western Research Laboratory, and their FTPmail address --
ftpmail@decwrl.dec.com -- is the most widely known (and widely used) FTPmail address in the world. Unfortunately, because of the traffic that this site sees, the decwrl address is also sometimes the slowest FTPmail site in the world.

There are other FTPmail servers around the world that may be closer to you, and that may actually be faster that the decwrl address :


Australia ftpmail@cs.uow.edu.au
Germany ftpmail@ftp.uni-stuttgart.de
Great Britain ftpmail@doc.ic.ac.uk
Ireland ftpmail@ieunet.ie
USA ftpmail@sunsite.unc.edu
USA ftpmail@ftp.uu.net
USA ftpmail@decwrl.dec.com
USA ftpmail@ftpmail.ramona.vix.com
USA ftpmail@win.net

Once you have found a site closest to you, you are ready to start sending commands to the FTPmail address. The commands need to be in the BODY of your e-mail letter. The body of you letter to the FTPmail site will actually have several commands in it. The basic FTPmail commands are, in order:

FTPmail command It does
reply <your Internet address> This tells FTPmail where to send the file(s) to.
connect <FTP site address> This tells FTPmail the site that you want it to connect to.
<transfer mode> This tells FTPmail if you want the files in ASCII or binary.
chdir <directory> This tells FTPmail in which directory the file that we want is located.
get <filename> This tells FTPmail to get a specific file.
quit Ends the FTPmail session.

In FTP example, we FTP'd to rtfm.mit.edu, got into the /pub/usenet/news.answers/ftp-list directory, and got the file faq. To do this using FTPmail, I need to send an e-mail a letter to ftpmail@sunsite.unc.edu (or to any other FTPmail site), and the body of my letter would look like this:

reply yoon@Old_Dominion_U.edu
connect rtfm.mit.edu
ascii
chdir /pub/usenet/news.answers/ftp-list
get faq
quit

[Note]: if you send this to an ftpmail site without changing the reply-to address, the ftpmail site will send the file to *me*, not to you. please change the reply-to address to your e-mail address.

A day or two after I send this letter to the FTPmail address, I should see the file sitting in my e-mail box. Notice that I said "should." The traffic at the various FTPmail sites is often incredible, and sometimes requests get lost. If this happens to you, you should just send your request again.

Now, the question becomes that 'how am I supposed to know which file(s) to request via FTPmail?' The answer is the "dir" command works just as well in FTPmail as it does in a regular FTP session. All you have to do is add the command "dir" after the "chdir" command to retrieve the directory listing.

reply yoon@Old_Dominion_U.edu
connect rtfm.mit.edu
ascii
chdir /pub/usenet/news.answers/ftp-list
dir
quit

BTW, FTPmail limits you to only one chdir command per letter.

If your system or local Internet service provider has any restriction on e-mail size, there is an additional command that you need to add to your list of commands

chunksize <size>

This command will break the files into chunks that your system permits. If your system has a 3,000,000 character (=about 2.93 MB) size restriction on a single e-mail from the Internet, your chunksize command should be

chunksize 2900000

(you want to make sure that you set your chunksize below what your system's restriction is). This command will break your file into 2,900,000 character chunks, and will then send the chunks to you.

Also, there's a service called TRICKLE, a concentrator of several FTP sites. Through TRICKLE you can retrieve files by e-mail or have them FTPed to your own machine or SEND to you. It's also possible to subscribe to directories or files (you can for instance subscribe to the McAfee Virus Scanner and get it by mail everytime there's a new version). Send e-mail with '/HELP' (no quotes) in the body to trickle@hearn.nic.surfnet.nl for more info and a list of other trickle servers.
Handling Binary Files through FTP Mail
  
The body of you letter to the FTPmail site will actually have several commands in the BODY of your e-mail letter. The basic FTPmail commands are, in order:

reply <your Internet address>
connect <ftp site address>
<transfer mode>
chdir <directory>
get <filename>
quit

(see FTP mail section for more information)

Binary file transfers using FTPmail aren't difficult ... they just require a few additional steps. Because all e-mail has to be in ASCII form, FTPmail has to encode your Binary file in ASCII before it can e-mail the file to you. Once you get the file, you can then decode the file back into Binary.

Fortunately, there are two ways that FTPmail can encode Binary files into ASCII. The first way it can do this is through something called "uuencode." As long as you have a "uudecode" program -- and uudecode programs are all over the place (chances are your site has uudecode stored on its system) -- the whole process is simple. Popular 'attachment' method widely used in e-mail program nowadays is actually based on this uuencode/uudecode method variant called 'MIME/Base64.' However, the big difference is that 'MIME/Base64' is transparent, i.e., e-mail program handles all en/decodings background and the user doesn't even have to worry about how to deal with ascii/binary conversion.

The second encoding type that you can use is called "btoa" (binary to ascii).

So, to get ASCII files using FTPmail, you would use the following commands in the body of your letter to the FTPmail address:

reply <your Internet address>
connect <ftp site address>
ascii
chdir <directory>
chunksize <size>
get <filname>

and to get Binary files using FTPmail, you would use the following commands in the body of your letter to the FTPmail address:

reply <your Internet address>
connect <ftp site address>
lt;uuencode or btoa>
chdir <directory>
chunksize <size>
get <filname>

How do I stop the listings from scrolling off the screen?
  
When you're retrieving a directory listing of a large site, it's quite possible that the number of files in a directory is bigger than the number of rows on your screen. The listing then scrolls of your screen. There are several ways to avoid this.

You can use ls -CF or ls -lF at "ftp>" prompt to get a 'wide' directory listing. Also, some ftp clients support: ls -l "| more" (yes, with double quotations) or dir "| more".

This seems to differ per site so trying some of the following might help you.

  • ls -l | more
  • dir | more
  • dir -1 | more
  • Ctrl-S(to stop the scrolling, Ctrl-Qto resume scrolling)
  • Alt-Scroll Lock (to pause the screen and restart it again)

These combinations are highly machine-specific but probably one of them will work for you. Also, instead of using dir or ls, you can try to retrieve an index file first to look at that. Either transfer the file and look at it while you're not connected to the ftp site (by using get filename), transfer the file and look at it while you're connected (by using a shell command, you temporarily leave the ftp client program to look at the file with some editor, cat or more, look in the help pages of the ftp client for more info, most of the time it's:

! more < filename

or something similar) or read the file while you're connected by retrieving it to the screen itself, use:
get filename.idx - (if you're working on a Unix system)
get filename.idx con (if you're working on a MS-DOS system)

Be aware that this is very useful for small files but is not a very good idea for large files (check the file size first before do this). My advice is to get some readme or index files first and then read them off-line so you know how the site is organized and where you can find things.
Where do I get anonymous FTP site listing?
     

"Salad a firm's own make; limpid red beet soup with cheesy
dumplings in the form of a finger; roasted duck let loose;
beef rashers beaten up in the country people's fashion"
-- POLISH MENU, from "Some Actual English Signs from Around the World"

O.K. We've been talking about how wonderful the anonymous FTP is, and how to get files. But where is the address list for those "wonderful" anonymous FTP sites? There are several sources you may xconsider to get a list of anonymous FTP addresses.

One of them is monthly posting at rtfm.mit.edu under /pub/usenet/news.answers/ftp-list/sitelist subdirectory. About 20 files containing zillions of anonymous FTP addresses, their host system information, descriptions of every possible type of files available in each site, and access restrictions are updated monthly. keep in mind that the size of each one of 20 files is huge.

Following is a couple of well-known popular anonymous FTP Sites for various main genre.

Anonymous FTP site What's there
archive.cis.ohio-state.edu Unix Software archive
wrarchive.cdrom.com Huge mirroring site for almost everything
cica.cica.indiana.edu Windows software archive
wuarchive.wustl.edu Windows software archive
oak.oakland.edu Windows software mirror
sumex-aim.stanford.edu Macintosh software archive

Unless you have "time" to burn, I'd suggest you to use Archie (Archive Server Listing Service) to search for a program available via anonymous FTP.

There are several of Archie servers scattered throughout the world, and Archie goes to every site that offers anonymous FTP files, collects the file structure from that site, and places it in an Archie database you can search. (see Archie)
Problems with connecting a Site
     

"Eschew obfuscation"
-- Groucho Marx

If you are unable to access the site because your computer doesn't seem to be able to 'find' the site (such as web/ftp program returns 'invalid host' or 'unable to resolve hostname' or some similar errormessage), try one of the following ways to see if the name of the site is known:

  • Telnet works on all systems as long as the system is hooked to the network. Telnet to the site and see if that works, if it does, there's either no ftp server active at the site or there's a configuration error with your ftp client program. Normally, the error message would be something like: 'I/O error on network device' or you do get a connection with the ftp server but it says 'Service not available. Remote service has closed the connection'.

  • Try 'nslookup sitename' or 'host sitename' and see what that gives. If they can't find the site, your nameserver (the computer that looks up the addresses of computers) doesn't know the site 'sitename'. You can try again in a couple of minutes if you think it might be a delay between 'sitename' and your machine. If that doesn't help then either your site has a deficient nameserver (ask your local system administrator to fix it) or the site 'sitename' does not exist.

  • Try is 'ping,' 'traceroute' or 'hopcheck' to see if there is a clear link (or path) to the machine 'sitename'.

  • Easy ways to check if the name 'sitename' can be found outside of your domain (i.e., odu.edu) is by mailing to one of the following addresses:

    service@nic.ddn.mil Use 'host sitename' as the subject of the message. Also other options, send 'help' as the subject.

    dns@grasp.insa-lyon.fr Put 'ip sitename' (no quotes) in the body or 'help' for an info file. Lots of options available.

If a problem appears while accessing the site or when retrieving a file, mail the problems to the system administrator of the site. When you report a problem, please be very explicit, i.e. don't write 'I can't get a file' but explain when it happened, what file it was, what system you are using etc. And word your message politely. It's no use to annoy an system administrator if you want a file from that site. (use your common sense)

If an system administrator address is not obtainable, attempt to use 'ftp@site_name'; replace 'site_name' with the name of the troublesome site. If it's very urgent, try sending a note describing the problem to 'postmaster@site_name' or 'root@site_name' (for Unix system) or 'operator@site_name' (for VAX/VMS machine). The 'postmaster@site_name' should be valid in all cases.