In the last lesson I showed you how to retrieve a text file using FTP. But how can a text file written on an IBM be read on an Apple Macintosh or on a Unix workstation? Its easy -- thanks to something called ASCII.
ASCII is the American Standard Code for Information Interchange, and it is the standard format for transmitting textual data. Any computer 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 is just 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, Microsoft Word files, Microsoft Powerpoint presentations, 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.
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 once you get it.
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
To change back to ASCII transfer mode, just type
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
BTW, how can you tell if a file is an ASCII file or a Binary file? Well, take a look at the extensions (remember, an extension is the stuff at the end of the file name -- the extension for CRISPEN.DOC is ".DOC"; the extension for SQUIRREL.TXT is ".TXT"). 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 a weird extension -- like ".gif" or ".zip" -- 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 :)
(First squirrels ... now ducks ... this workshop is getting to me.)
Let's say that I want to get every file in a particular directory with the word "duck" in it. I would type
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
duck1.txt duck2.txt
ducksoup duck.gif
Where I place the wildcard in my mget command will determine
what files I get:
mget command: files it would retrieve:
mget duck* duckreport.doc; ducket.exe; duck1.txt;
duck2.txt; ducksoup; duck.gif
mget duck*.txt duck1.txt; duck2.txt
mget duck.* duck.gif
Before you continue on, take a minute and try to figure out why
each of the mget commands retrieved different files. If you can
figure it out -- and believe me folks, this is EASY -- you will
be a master of the mget command :)
The steps in a basic ftpmail session are pretty easy:
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 :( <--- a frowning smiley
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
France ftpmail@grasp.insa-lyon.fr
Germany ftpmail@ftp.uni-stuttgart.de
Great Britain ftpmail@doc.ic.ac.uk
Ireland ftpmail@ieunet.ie
Sweden ftpmail@lth.se
USA ftpmail@sunsite.unc.edu
USA ftpmail@ftp.uu.net
USA ftpmail@decwrl.dec.com
Once you have found a site closest to you, you are ready to start
sending commands to the ftpmail address! The commands, just like
all of the LISTSERV commands that I drilled into your head earlier
in the workshop, 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:
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 pcrispe1@ua1vm.ua.edu
connect ftp.sura.net
ascii
chdir /pub/articles
get fall91.issue
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 :)
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 :)
By the way, the "dir" command works just as well in ftpmail as it does in regular FTP! All you have to do is add the command "dir" after the "chdir" command:
reply pcrispe1@ua1vm.ua.edu
connect ftp.sura.net
ascii
chdir /pub/articles
dir
quit
(\__/) .~ ~. )) /O O `./ .' PATRICK DOUGLAS CRISPEN {O__, \ { PCRISPE1@UA1VM.UA.EDU / . . ) \ THE UNIVERSITY OF ALABAMA |-| '-' \ } )) .( _( )_.' Roadmap: Copyright 1994 Patrick Crispen. '---.~_ _ _& All rights reserved. The views expressed in this letter do not necessarily represent the views of the University of Alabama - Tuscaloosa.
Go back to the Syllabus
MAP16:
FTP File Compression
MAP14: FTP (Part Two)