Online Resources
 Internet Technology 
 HTML 
 Web Design 
 Business/Web Admin 
 Perl/CGI/DHTML 
How to use File Transfer Protocol: An Introduction

Introduction
File Transfer Protocol (as the title suggests) is used to transfer files from other computers. FTP can be used to transfer files to or from your accounts on two different computers, i.e. you could transfer files from itwebmaster.iit.edu to another computer on the Internet. When you use FTP in this way, you log on to the remote computer using you own username and password, and you are in your own directory initially.

Another common use of FTP is to access resources that someone has made available on the Internet through an anonymous FTP site. This is a means of allowing anyone on the Net to login with an FTP session and send or receive files from the anonoymous FTP server. This is a way of making files accessible to the world.

FTP is a line-mode (i.e. text based) type of Internet tool. The commands are pretty simple and there aren't very many of them, but there are no menus to fall back on!

On a UNIX or Linux server (like itwebmaster.iit.edu) FTP is started by typing ftp which starts the FTP program (makes sense to me....) and the name of the site you wish to FTP to.

To start FTP in Windows95/98/ME/NT/2000/XP, just click on Start;
when the pop-up menu appears, select Run;

and when the Run dialog box appears, type itwebmaster.iit.edu or wherever it is you want to FTP to.
 
If it is somewhere that you have an account (like itwebmaster), you login with your own username and password. If it is an anonymous FTP site, you must log on as "anonymous" (and you must spell it right, also), and give your full email address (i.e. username@itwebmaster.iit.edu) as your password. This is proper Netiquitte as it does get logged by the system you have FTP'ed to; they like to know who is using their FTP site.

Let's retrieve a file by anonymous FTP

Here's what opening an anonymous FTP sessions looks like
itwebmaster> ftp ftp.microsoft.com
Connected to ftp.microsoft.com.
220 ftp Windows NT FTP Server (Version 3.5).
Name (ftp.microsoft.com:rgret555): anonymous
331 Anonymous access allowed, send identity (e-mail name) as password.
Password:
230-
|
| Welcome to ftp.microsoft.com (a.k.a gowinnt.microsoft.com)!
|
| Please enter your "full e-mail name" as your password.
| Report any problems to ftp@microsoft.com
|
| Refer to the index.txt file for further information
|
230 Anonymous user logged in as anonymous.
ftp>
Notice that when login was requested, we logged in as anonymous.
 
Once the ftp> prompt appears it's time to get the files. But how do we know what's there? Simple. We type dir:
ftp>
 200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
dr-xr-xr-x   1 owner    group               0 Oct  7  1994 bussys
dr-xr-xr-x   1 owner    group               0 Oct  7  1994 deskapps
dr-xr-xr-x   1 owner    group               0 Dec 21  1994 developr
-r-xr-xr-x   1 owner    group            7657 Mar  2  9:47 dirmap.htm
-r-xr-xr-x   1 owner    group            4376 Mar  2  9:39 dirmap.txt

-r-xr-xr-x   1 owner    group             712 Aug 25  1994 disclaimer.txt
-r-xr-xr-x   1 owner    group             860 Oct  5  1994 index.txt
dr-xr-xr-x   1 owner    group               0 Mar 23 16:21 KBHelp
-r-xr-xr-x   1 owner    group         5711384 Mar 23  3:54 ls-lR.txt
-r-xr-xr-x   1 owner    group          711612 Mar 23 17:10 ls-lr.Z
-r-xr-xr-x   1 owner    group          554946 Mar 23  3:55 LS-LR.ZIP
-r-xr-xr-x   1 owner    group           28160 Nov 28  1994 MSNBRO.DOC
-r-xr-xr-x   1 owner    group           22641 Feb  8  1994 MSNBRO.TXT
dr-xr-xr-x   1 owner    group               0 Oct  7  1994 peropsys

dr-xr-xr-x   1 owner    group               0 Nov  2  1994 Services\
dr-xr-xr-x   1 owner    group               0 Mar 10  9:46 Softlib
-r-xr-xr-x   1 owner    group            5095 Oct 20  1993 support-phones.txt
-r-xr-xr-x   1 owner    group             802 Aug 25  1994 WhatHappened.txt
226 Transfer complete.
1271 bytes received in 0.75 seconds (1.7 Kbytes/s)
ftp>
OK, there's a lot of stuff there. Some of these entries are directories; we know that because the very first letter in the line is a 'd' which means it's a directory. If we wanted to retrieve something that was in a lower level directory, we would have to issue the command 'cd' followed by the name of the directory in order to change directories.
Now it's time to get a file. We'll get the dirmap.txt (text) file, which is pretty short. Besides that, we are in ASCII (text) transfer mode (by default); we'd have to type binary to transfer a program file or a compressed file such as LS-LR.ZIP. To get a file we use the get command and the filename
ftp> get dirmap.txt 
200 PORT command successful.
150 Opening ASCII mode data connection for fs500a.txt.
226 Transfer complete.
local: dirmap.txt remote: dirmap.txt
886 bytes received in 0.31 seconds (2.8 Kbytes/s)

ftp>
To see the file we have retrieved, exit from FTP by typing quit

Once we have quit the FTP program, we type
cat dirmap.txt to see what we've got!

Sending files...

If I wanted to send a file named bogus.txt, I would simply type either send or put and the file name.

ftp> send bogus.txt

To send a group of binary files we would enter.

ftp> binary

to start the binary mode (remember, the default is ASCII (text)
mode), and then enter
.

ftp> mput *.gak

which would send all the files with the .gak file extension; mput stands for multiple file put.

When we are done we simply type bye or quit (exit won't work; what, you were expecting consistency in your anarchy?)

All of the FTP commands you will ever need:
(There are more but they're pretty technical...)

Frequently Used FTP Command List

?		print local help information
ascii 		set ASCII transfer type
binary		set binary transfer type
bye		terminate ftp session and exit
cd 		change remote working directory
cdup		change remote working directory to parent directory
close		terminate ftp session
delete		delete remote file
dir		list contents of remote directory
disconnect	terminate ftp session
get		receive file
lcd		change local working directory 
		(use lcd a:\ with Windows FTP to use the 
		floppy as your local directory)
ls		nlist contents of remote directory
mdelete		delete multiple files
mdir		list contents of multiple remote directories
mget		get multiple files
mkdir 		make directory on the remote machine
mput 		send multiple files
open		connect to remote tftp
prompt		force interactive prompting on multiple commands
put 		send one file
pwd		print working directory on remote machine
quit		terminate ftp session and exit
recv		receive file
remotehelp	get help from remote server
rename		rename file
rmdir		remove directory on the remote machine
send		send one file
status		show current status
user		send new user information

There is command line help available from FTP by typing help and the command you want help on (but you'll just see what's listed above)

You can FTP using World Wide Web browsers; it is frequently much easier because it will display the contents of text or graphics files and download binary (program) files. With a browser you can only download unless you are using Microsoft Internet Explorer (Windows) or Konqueror (Linux).

You can also use a graphical FTP client such as SmartFTP (Windows) or Cyberduck (Mac) for file transfers. For a full list of Mac GUI FTP clients, see http://www.macorchard.com/ftp.html (...still looking for as nice a list for Windows).

Secure FTP (SFTP)
SFTP uses SSH (secure shell) to provide an encrypted channel for login and file transfer commands; files being transferred are not encrypted but the process surrounding the transfer is. Ideally you should never use an unencrypted login over the Internet, so the use of SFTP is far preferable to just plain FTP. It'is interesting to note that if a system has an SSH server, it almost invariably has an SFTP server included, so if you have SSH access you probably have SFTP available as well. If you need SFTP, try WinSCP or Filezilla (Windows), Cyberduck (Mac) or Konqueror (Linux). If you are seriously into the command line and want to use command line SFTP on Windows, try psftp from the maker of the PuTTY SSH client; the SFTP command line client is already built into Mac OS/X and Linux.

Evaluating files you find at an FTP site
The name of the directory that a file is in can give you important clues as to the types of files you might find there. For example, a directory named /pub/programs/code will have a bit different type of files than one called /pub/food/recipies. File extensions are also an important way to evaluate a file.

Frequently files are compressed or converted to text files to make them move faster across the Internet. These files can usually be identified by their file name extensions. All of the compressed or converted-to-text files require special software to return the files to their original format; for PCs available decompression programs include ZipGenius, TUGZip, WinZip, PKZip, and Stuffit Expander; for the Macintosh it's Stuffit. To expand .bin, .sit, .sea, and .hqx on a PC, you really need Stuffit Expander.

Of the formats listed below, only .txt and .c files are immediately viewable from a terminal session. Macintosh and UNIX or Linux files can have multiple file extensions, i.e. filename.tar.Z is a compressed UNIX or Linux archive file.

Some common ftp site file extensions include:
.zip DOS/Windows compressed file .gif 256 color bitmap graphic file
.Z UNIX or Linux compressed file .jpg 16 million color bitmap graphic file
.gz UNIX or Linux (gnu) compressed file .tif Bitmap graphic file; b&w or color
.tar UNIX or Linux archive file .bmp Windows bitmap file
.sit Macintosh compressed file .wmf Windows metafile vector graphic
.sea Macintosh compressed file .pict Macintosh bitmap graphic file
.uue DOS file converted to text .ai Adobe Illustrator graphic file
.hqx Macintosh file converted to text   .eps Encapsulated Postscript file
.exe DOS/Windows program file .txt Text file
.au UNIX or Linux audio file .tex File in TeX DTP format
.wav Windows audio file .ps Postscript file
.c 'C' program source code .pdf Adobe portable document format

  © Page content Copyright 1998 Ray Trygstad; used by permission.


| Home | About... | How do I...? | Modules | Resources |
Last Updated by Ray Trygstad on 09/05/05 | Copyright 2004 Illinois Institute of Technology