File Transfer Protocol (ftp) developed at Berkeley is a separate communication or connection program that is used automatically by some browsers. It can also be used explicity as a utility from your shell acount. The following is a description of the use of ftp from your shell account.
I'll assume that you have read the section on logging in to your shell account and familiarized yourself with the what you can do under the shell.
As under dos, a program or utility is started up by using its name on the command line. Commands generally take both options and arguments. The 'ftp' utility takes no options, but takes an optional single argument. The most efficient way to use ftp is with the argument. The argument is Fully Qualified Domain Name of a computer system on the internet for which your you actually have an account, or a computer system which allows "anonymous ftp login". If you have an account on the remote system then you will use the login name and password for that account. More likely you will be accessing an anonymous ftp site. These pages contain a link to a list of anonymous ftp sites.
What do anonymous ftp sites have that I might be interested in? Mostly, such sites are archives of various kinds of files: FAQ documents for various usenet news groups are contained in the archives of
rtfm.mit.edu and pit-manager.mit.eduArchives of backissues of various electronic journals and magazines are also frequently available from ftp sites. Software either in binary or source code are also maintained at certain sites.
tsx-11.mit.eduis a repository for source code of many programs that are at the "beta stage". Many documents directly concerned with internet standards (RFC, FYI, STD) documents and structure are at
nic.merit.edu and farnet.orgThis should pretty much explain what ftp sites are good for.
Accessing the site:
On the command line use, for example
ftp nic.merit.eduThis should make the ftp connection with nic.merit.edu. Under heavy use, a site may refuse the connection and suggest that you try later. You don't have much choice. There is a more elaborate method. Use as command
ftpThis returns an ftp prompt but makes no connection
When the connection is made, you will probably see a full screen of written material concrning the site and its use. Remember that your use of an "anonymous ftp site" is not a right, but a privilege. Someone is opening their home to you, computer though it may be, and the same common sense rules of courtesy apply. Some considerations, however, are not so much common sense and need little explanations as we go along here. Read the opening screen message carefully, and certainly comply with any requests. Even if the site does not demand it, it is conventional courtesy to login using "anonymous" as the login name and your email address as the password. Clearly "anonymous ftp login" is not exactly anonymous. Bear in mind that some ftp sites can capture your email address regardless of what you enter; it is best not to play games.
So are now logged in by ftp and are presumably looking for something. There are various command that ftp understands, most of which, not surprisingly, have to do with file transfer. You do *not* have to stay on line and connected to the remote site to search the entire archive, by hand. Unlike an http connection, which gracefully connects and disconnects to the designated URL as needed, an ftp connection is fixed. This puts the onus of politeness more squarely on you. In this case, "politeness" means not only conforming to the house rules, but by limiting your connect time and generally *not* using the very powerful and system intensive command
ls -lR = list in long format recursively, every file and directory found beneath the present working directory (See already prepared files below.)Remember that that there are quite literally millions of people who are potential accessors for this site. You limit your connect time by knowing what you're doing. This document is supposed to give you the requisite knowledge to be polite. Most sites keep index files that can be recognized by their name. When you are first logged in and see the
ftp>prompt, there are two commands that useful for orienting yourself. The command 'pwd' is recognized and should be familiar. The most probable response will be "/", indicating that you are positioned at the top of the file system. The command 'ls' or the command 'dir' is recognized and will list the contents of the root directory. The file and directory names should be in the rightmost column. Look for files whose names are any of:
Possible name extensions README .txt index, Index, INDEX .zip ls-lR, ls-Rl .gz .z .Z .tar .tar.gzThese are the files should be downloaded to the server of your access provider or to your own computer if appropriate, and read first. Find what you want, and then reconnect to download the desired file(s). Notice, with an 'ls' command, the leftmost character will be either '_' signifying a file or 'd' signifying a directory. The output of 'ls' under ftp is same as under a unix shell. You cannot download an directory as any attempt to do so will readily show.
File name extensions and their significance:
none .txt A standard ascii text file. .z Ambiguous in compression scheme, but - a "binary" file. Possible compression schemes: zip, pkzip, "old" unix pack. .Z A file that has been compressed by the unix 'compress' utility - a "binary" file. .zip A file(s) or directory that has been compressed by either 'zip' or 'pkzip' - a "binary" file. NOTE: zipping can be nested: after an 'unzip' there may be files that still need to be unzipped again. .gz A file that has been compressed by the GNU gzip/gunzip utilities - a "binary" file. .tar Usually a directory archive file created by the venerable 'tar' (originally "Tape ARchive") utility of unix - a binary file. .tar.gz A tar archive which has then been gzip'd. This may be the cleanest way of archiving entire directories, and the easiest to undo - also a binary file.
Why do I bother with such sordid details? Your ftp connection supports two modes of transfer
"ascii" and "binary"One of these modes is set as the default when you finish logging in. Although some sites have smart software that will set the transfer mode that is appropriate to the file you are downloading, some do not.
1) ascii files dowloaded in either mode will give good files. 2) binary files dowloaded in binary mode will give good files. 3) binary files dowloaded in ascii mode will give *garbage*.On most systems you can and should, as a matter of course set the appropriate transfer mode by issuing as a command to ftp either "ascii" or "binary".
Changing to the Appropriate Directory
The change directory command 'cd' works in ftp just as it
does from a unix shell.
The command 'cdup' is an alias for 'cd ..'.
Sometimes, backing up on an ftp command line may not work and
instead just generates '^H' characters which are literal backspaces.
If you encounter the problem, just hit the ENTER key and be prepared
for an error message about "no such file or directory".
It pays to type carefully.
If the pathname of your goal directory is long, try taking it in steps.
An 'ls' or two along the way is fine.
Downloading a single file
Now, you've gotten yourself positioned in the right directory,
and an 'ls' has shown the right file name.
Be sure that it *is* a file and not a directory.
(The following will work for only *one* file.)
ftp> get filenamewhere filename is the name of the file you want. Remember, you are accessing a unix system: file names are case sensitive. Type any upper or lower case letters exactly.
1) Some flavors of generic unix allow very long file names, and some people make use of this freedom. Just take entering the file name slowly and accurately. 2) There are certain characters that have special meaning to unix shell. These are called metacharacters; more mundanely in DOSese they are referred to as "wild cards". It has been convention and practice in years of unix past *not* to use these metachracters in the naming of files and directories, precisely because it makes referencing the files and directories so named difficult, clumsey and arcane. That convention is now sometimes *not* adhered to. The assumption behind their use is either 'let's be perverse' or that the user knows unix and will not be fooled. The standard shell metacharacters that mess up referencing and that are used, are: [ ] ( ) { } < > ? * & $If you see any of these characters in the filename, when typing the filename for the ftp "get", precede the metacharacter with a backslash (not the forward leaning slash used to construct pathnames). The backslash is the unix "escape character". An ftp "get" allows a second argument. The command line
ftp> get filename file2will retrieve "filename" on the remote ftp server copying it to your server under a new name "file2".
Dowloading multiple files
To dowload more than one file with a single command,
replace "get" with "mget". The command line will look like
ftp> mget file1 file2 file3 ... filenThe locution
ftp> mget file?may work on some systems, but most often, the locution
ftp> mget *is disallowed. When using "mget", there is an automatic interrogation of the user (y/n) to transfer the next file. You can turn this off by
ftp> promptThis is a toggle switch command that turns such prompting on and off. If the impending transfer by either "get" or "mget" is known to be large it is helpful to issue the command
ftp> tickbefore the file transfer command. This will cause a display of the progress of the transfer and show up any hanging that might occur during the transfer. This prevents sitting there for half an hour just woundering whether the file is bigger than you thought.
When the file transfer has terminated and the ftp-prompt has returned
ftp> byewill disconnect the remote ftp connection and return your shell prompt.
I've discussed only the *essential* ftp commands. See the crib sheet below for the full list. Most of them you will not need.
A final comment on Mirrors and Politeness. For much accessed archives and repositories there are mirror sites which duplicate the files of a primary repository. It is good netequette to retrieve from the closest site. If you can retrieve files from a mirror site of material originating in Finland, do so rather than accessing the originating site.
The command syntax of ftp is designed so that it can be invoked and manipulated within "shell scripts" and so that ftp usage can be automated. To go further than that brief comment would mean requiring a greater knowledge of unix shells and their use as programing languages.
FTP CRIB SHEET Syntax ftp <Fully-Qualified-Domain> ftp> or ftp ftp> open <Fully-Qualified-Domain> Ftp Commands ftp> help Commands may be abbreviated. Commands are: ! debug mget pwd status $ dir mkdir quit struct account disconnect mls quote system append form mode recv sunique ascii get modtime reget tenex bell glob mput rstatus tick binary hash newer rhelp trace bye help nmap rename type case idle nlist reset user cd image ntrans restart umask cdup lcd open rmdir verbose chmod ls prompt runique ? close macdef proxy send cr mdelete sendport site delete mdir put size Ftp command synopsis: ! <cmd> Run command on local system $ execute macro account send account command to remote server append Set to append transferred file to an existing one ascii Set xfer protocol for text files bell beep when command completed binary Set xfer protocol for text files bye Close ftp connection case toggle mget upper/lower case id mapping cd Change directory on remote system cdup = cd .. on remote system chmod chmod on remote system close = bye cr on/off toggle of using ^M at EOL or not delete delete remote file debug toggle/set debugging mode dir List directory contents in DOS format disconnect terminate ftp session (don't exit ftp) form set file transfer format get [get rfile | get rfile lfile] Transfer one file to local glob toggle metacharacter expansion of local file names hash on/off toggle: Show stats on bytes xferred and yet to be xferred help [help | help <cmd>] Display above message without argument idle get (set) idle timer on remote side image = binary lcd change directory on local system ls List in unix ls -l style macdef define a macro mdelete delete multiple files mdir list contents of multiple remote directories mget [get rfile1 rfile2 ...] get multiple files mkdir mkdir on remote system mls list contents of multiple remote directories mode set file transfer mode mkdir Make directory on remote system mput [put rfile1 rfile2 ...] put multiple files newer get file if remote file is newer than local file nmap set templates for default file name mapping nlist nlist contents of remote directory ntrans set translation table for default file name mapping open open connection to named site prompt toggle on/off default prompts between multiple get/put proxy issue command on alternate connection sendport toggle use of PORT cmd for each data connection put [put lfile | put lfile rfile] Transfer one file to remote pwd pwd on remote system quit = bye quote send arbitrary ftp command recv receive file reget get file restarting at end of local file rstatus show status of remote machine rhelp get help from remote server rename rename file reset clear queued command replies restart restart file transfer at bytecount rmdir Remove directory on remote system runique toggle store unique for local files send send one file site send site specific command to remote server Try "rhelp site" or "site help" for more information size show size of remote file status show current status struct set file transfer structure system show remote system type sunique toggle store unique on remote machine tenex Set transfer mode to DEC TOPS-10 format tick toggle printing byte counter during transfers trace toggle packet tracing type Display the transfer mode: ascii, binary, image, tenex user Specify user name to remote system umask get (set) umask on remote side verbose toggle verbose mode ? = help Useful Locutions (that don't always work!): ftp> ls *.txt | more Displays the listing through the paginator ftp> get README | more Displays the file README rather than transferring to local system ftp> get README "| grep <pattern>" Displays the lines of README with pattern ^C Should stop a file transfer, if not ^\ will most certainly do it.