The Text Based Internet
Part 5: Uploading/ Downloading files with File Transfer
Protocol
The File Transfer Protocol (FTP)
Simply put, FTP is a way to get a file from one place to another.
With a few simple commands, you can download files, programs and even
operating systems. (Downloading OS's takes a very long time, for the
record.)
There are many FTP programs out there, many with nice, shiny GUI
interfaces. All of the browsers that I have used even have download FTP
capabilities built in. You don't need these. For FTP, all you need is a
computer on the internet, whether it's a dial-in UNIX shell or windows
with a PPP connection. Text based FTP is much faster, and all you need to
know is a few simple commands.
How to FTP
For example purposes, I will FTP to Netscape and download something.
While you can download from commercial sites, few
will let you upload.
The first thing that you want to do is make sure that you are in the
directory that you want the files to be loaded to or from. It's much
easier to plan ahead.
Now, from the command prompt, type ftp ftp.netscape.com.
[otto@shell internet]$ ftp ftp.netscape.com
220 ftp105 SGI 1.5: FTP server (Version wu-2.4.2-academ[BETA-17](20) Sat
Jan 23
23:20:31 PST 1999) ready.
Name (ftp.netscape.com:otto):
This is where you log in. If you are not employed by, a friend of or
paying the owner of the ftp site, chances are you will not have a login
for the site. This means that you will have to access the site
anonymously. Many sites allow anonymous ftp. Many do not. Big
companies, educational institutions and software distributors usually do.
Why not
try it? Log in either as anonymous or ftp.
Name (ftp.netscape.com:otto): anonymous
331 Guest login ok, send your complete e-mail address as password.
Password:
For your password, use your full e-mail address. It will not show you
what
you typed.
230-Welcome to the Netscape Communications Corporation FTP server.
230-
230-If you have any odd problems, try logging in with a minus sign (-)
230-as the first character of your password. This will turn off a feature
230-that may be confusing your ftp client program.
230-
230-Please send any questions, comments, or problem reports about
230-this server to ftp@netscape.com.
230-
230-*********** October 13, 1995 **********
230-Private ftp is now only on ftp1.netscape.com. Anonymous is supported
on
230-ftp 2 through 8. If you are accessing a named account please use
ftp1.
230-
230 Guest login ok, access restrictions apply.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>
The first thing that you always want to do when you log in is type
binary at the prompt.
ftp> binary
200 Type set to I.
Binary and ASCII are the two transfer types that ftp uses. Binary is
more reliable, and the only way you can transfer any non text based file.
Sure, it's a little slower, but trust me, there's nothing worse than
downloading a file for an hour to have it not work because you were not
using binary mode.
Help
If you type help at the prompt, this is what you get.
debug mdir sendport site
$ dir mget put size
account disconnect mkdir pwd status
append exit mls quit struct
ascii form mode quote system
bell get modtime recv sunique
binary glob mput reget tenex
bye hash newer rstatus tick
case help nmap rhelp trace
cd idle nlist rename type
cdup image ntrans reset user
chmod lcd open restart umask
close ls prompt rmdir verbose
cr macdef passive runique ?
delete mdelete proxy send
These are all of the commands that you can use in FTP. Don't worry,
you don't need to know them all. Just notice that there are some that are
the same except that there's an m in front of one; delete and
mdelete, get and mget, put and mput. You get the picture. When there is
an m in front of the command, it means multiple files. You should
use the m
command whenever you are using wildcards, like *. For an example,
if I want to download all of the files in a directory that start with a t,
I type mget t*.*.
If you would like more in-depth help on a command, type help and
then the command name.
ftp> help mget
mget get multiple files
ftp> help get
get receive file
ftp> help ls
ls list contents of remote directory
ftp> help put
put send one file
ftp> help mput
mput send multiple files
ftp> help bye
bye terminate ftp session and exit
ftp>
Okay, it's not very verbose, but it really is all you need to know.
Commands
The first command that we will look at is ls. Ls gives
you a list of the files and directories of the directory that you are
ftping into. It is a lot like the dir command in DOS.
Type ls at the prompt.
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
total 8
drwxr-xr-x 7 root other 71 May 4 1999 .
drwxr-xr-x 7 root other 71 May 4 1999 ..
d--x--x--x 2 root other 20 Apr 20 1999 bin
dr-xr-xr-x 2 root other 22 Apr 20 1999 dev
d--x--x--x 2 root other 78 Apr 20 1999 etc
dr-xr-xr-x 2 root other 60 May 4 1999 lib32
drwxr-xr-x 23 888 999 4096 Oct 6 15:31 pub
226 Transfer complete.
ftp>
The first thing that you see is an odd (if you're unfamiliar with unix)
string of letters. For the last file listed, pub, you get
drwxr-xr-x. The first letter is a d. This simply means that
it's a directory, or folder, where other files are held. The other 9
letters tell you who can do what to the directory. The last three
letters, r-x are the ones that are important to us. This means
that anyone can go into the directory, they just can't change anything.
The last column lists the file name. Type cd pub and it will
take you to pub, the public folder.
After typing ls to get another directory listing, you decide to
download the readme file. Read me's usually contain some directions for
using the ftp site, notes about the organization, info about what is
contained in the directory it's in, and other miscellaneous information.
generally, you will want to read these, especially if you are having
problems.
There are 2 commands that you can use to get the file. Because it is a
single file, Readme.htm, you can use get Readme.htm. In truth,
that will work, but if you are lazy like me, you will want to use
wildcards.
The wildcard that I always use is *. There are others, of
course,
but I've used them personally once or twice in my life, so lets keep it
simple and just talk about the *. * means that the computer should look
for the file name with any amount of letters where the star is. If you
type Rea*, it could mean Readme, Readme1, Reaper, or any other file that
starts with a Rea.
In order to use wildcards, you must use the multiple file get command,
"mget".
ftp> mget Rea*.htm
mget ReadMe.htm?
Now type a y to verify that you want the file.
200 PORT command successful.
150 Opening BINARY mode data connection for ReadMe.htm (34832 bytes).
226 Transfer complete.
34832 bytes received in 1.74 secs (20 Kbytes/sec)
The file is now in the directory that you were on on your local
machine. Now log off by typing bye.
ftp> bye
221 Goodbye.
Uploading is the exact same process. Keep it easy on yourself, get
into the right directory before ftping. Follow the same process, using
the commands put and mput instead of get.
When things go wrong
After I download the file it doesn't work! This happens to me
constantly. I spend an hour downloading a file only to find that it does
nothing when I try to run it. The problem is, I always forget to put it
in binary mode, without fail. Ascii mode only works for things like text
files, html documents and the few other things in this world that are text
based. If it turns out that the binary thing is not the problem, you may
want to try redownloading it. Line noise, someone picking up the phone
while you are downloading, and other conditions can cause the file not to
transfer right. If it still doesn't work after 2 tries, the file quite
possibly could be bad. Try downloading something else. If it doesn't
work, you may want to have a tech look at your computer, the modem may be
bad.
Whenever I push backspace, I get a bunch of ^h's all over the
place. Again, this is a simply solved problem that I always do. Don't
push backspace, push delete. The backspace key is not set
up as
a default in the UNIX environment. So, when you are logging in or using
ftp, you can not use the backspace. This problem has generally been
solved for any other task. Don't worry about it, just don't use it.
I type everything correctly, it just can't find the file or won't
take the command. UNIX, including the FTP program, is case sensitive.
Make sure that your caps lock is off, and type the file EXACTLY how it is
written. If the file is called Readme.HTM, calling it README.HTM,
readme.htm, or even Readme.htm will not work. For commands in FTP, all of
them are lowercase, and will not work if you type them any other way.
I forgot to put it in the right directory before I FTP'ed in. How
do I change directory without logging out and back in? You use the
lcd command. If you type lcd, it will tell you what directory you
are in. lcd .. will take you to the next higher directory and
lcd directoryname will take you to another directory. Of
course, this is very limited, so that's why I say get to the right
directory first.
I can't change to a directory/download a file because there's a
space in the file name. The only solution to this problem is to write
the administrator of the site and complain that they don't make their
files accessible to everyone. Of course, this letter of complaint will
not be very successful if you write it to ftp.microsoft.com.
- You can check your mail through Pine.
- You can check out the newsgroups through tin.
- While you're at it, you should fiddle around with some miscellaneous commands and programs.
|