Command-Line FTP for Beginners
Although command-line FTP is the hardest method to use, it is
ubiquitous to the UNIX world and nearly so to the PC platform. This method is
seldom seen implemented for the MacOS directly, unless a connection to a remote
host is made first. Under UNIX, you may just type ftp at the
command prompt to start the program that UNIX uses to transfer files. The same
will probably be true if you are running some version of Windows.
A sample "anonymous" FTP session
To initiate a connection to our FTP server, type
ftp ftp.microimages.com
After the normal waiting period (allow for Internet traffic)
you should see something in the form of:
Connected to ftp.microimages.com.
220-====================================================
220-MicroImages FTP Server
220-All transfers are logged.
220-====================================================
220-
220 tnt FTP server (Version wu-2.4(2) Thu Dec 1 08:30:25 CST 1994) ready.
Name (ftp.microimages.com:csl):
At the Name prompt, type anonymous
and hit <return>, unless you have been directed otherwise by MicroImages.
Then the server will prompt you for a password. Enter your entire email
address as the password.
331 Guest login ok, send your complete e-mail address as password.
Password:
After you enter your complete email address and hitting the
<return> key, (if login was successful) the computer displays:
230-Welcome to the MicroImages FTP server.
230-If you are expecting something from us, look in /pub/outgoing
230-If you're sending us a file, cd to /pub/incoming for instructions
230-All transfers are logged.
230-
230 Guest login ok, access restrictions apply.
ftp>
The last line on the screen is the new ftp>
prompt. You are now logged in anonymously to MicroImages' FTP server in
Lincoln, Nebraska USA. From here you may change directories, browse directories
and download or upload files. If you are interested in transfering files, the
first thing that you should do is type cd pub because all of the
things that will be of interest to the FTP user are found below the /pub
directory. If you type pwd the server tells you what directory you
are in at any time. Typing ls will give you a listing of files in
the current directory.
The Command-Line: Basic steps
In a nutshell, here are some of the basic steps you will take
to transfer a file to/from MicroImages.
- Connect to the server and login anonymously
- Navigation Commands
ls
To see what's in the current directory.
cd dirname
To change your current directory to dirname.
pwd
To tell what directory you're in now. (Think "print working
directory.")
- Directory Creation for Uploading files (in /pub/incoming
only)
cd /pub/incoming
Go to uploading area.
ls
Make sure that there is no directory with the same name that you're
going to use, so that you don't overwrite a pre-existing directory.
mkdir dirname
Make a directory named dirname.
cd dirname
Go to the directory you just created.
- File Transfer Commands
binary
Switch to binary file transfer mode. Transferring binary files in ASCII
text tranfer mode will botch them. You can always type binary
to make sure that you're in binary mode.
ascii
Switch to ASCII text transfer mode. Do this only if you're sure that
you're what you're transferring is a plain text file. The ASCII
mode will alter the file as it transfers between the two machines so
that newline, linefeed, and carriage return characters are correct on
the destination machine. If you're not sure what kind of file you're
dealing with, just use the binary mode to transfer files.
get remote_filename local_filename
Download a file to your computer. remote_filename refers to
a file already existing on the server, local_filename is
the name under which you would like to save remote_filename
on your computer.
If you don't specify local_filename, the new copy on your
machine has the same name as remote_filename. if you don't
want to explicitly name the file you're downloading.
put local_filename remote_filename
Upload a file to the server. local_filename refers to a
file already existing on your computer, and remote_filename
is the name under which you would like to save local_filename
on the server. If you don't specify remote_filename, the
new copy on the server has the same name as local_filename.
prompt
This command toggles on/off the "interactive mode", i.e. if
you want to transfer multiple files with one command and you're in
interactive mode, ftp will ask you to confirm each transfer. If you want
to transfer multiple files with one command and you're not in
interactive mode, the files will be quietly transferred without ftp
asking you to confirm each transfer. This is most useful in conjunction
with the commands shown below.
mget filename_1 filename_2 ... filename_n
Download all files specified. If you want to download all the files in
the current working directory, type mget *. The *
is called a wildcard character and matches each file.
mput filename_1 filename_2 ... filename_n
Upload all files specified. If you want to upload all the files in the
current working directory, type mput *. The *
is called a wildcard character and matches each file.
- Getting Help
help (no arguments)
Generate a list of all available commands.
help command
Basic information about what command does.
- Closing, Quitting, Reconnecting
close
To close the connection with the host
open hostname
To open/reconnect to the host hostname.
bye
To quit the FTP application. Typing bye while still
connecting is a fast way to close your connection and quit the FTP
application at the same time.
- Please be sure to close your connection with the FTP
server when you have finished. This frees up unused resources so that
everyone can have better service.
Graphical User Interface FTP programs
Graphical interface programs are largely self-explanatory.
Whether you're uploading or downloading files, you first need to make a
connection. Your GUI FTP program will probably give you several fields to fill
in, such as location, username, password, and destination directory. For
location, enter ftp.microimages.com. Specify anonymous
as the user name, and your full email address as the password. If you
know the name of the directory that the files are in, you can specify that as
well, in order to save time. Most GUI FTP programs allow point-and-click
navigation of directories, which may make you wait for a new list each time you
select to change a directory. The common way to download a file is to select it
with the mouse, and click a button to initiate the download.