8.4 File Transfer
VI. File Transfer
1. FTP (File Transfer Protocol) permits copying files from one
internet host to another.
Downloading: Copying files from the remote computer to yours
Uploading: Copying files from your computer to the remote
computer
2. Requirement: You need accounts (with passwords) on both the local host
and the remote host.
There is a special account (anonymous, E-mail address as password)
that users can access while unregistered for certain internet hosts that are
set up to offer this service.
3. Benefits of Anonymous FTP:
* Huge Number (Thousands) of Sites for downloading files
* Largest distributed library of information ever accumulated
* Library that is always growing, never closes, covers myriad
topics
* All this is Free
* A principal way of distributing software on the internet
* Used to archive and disseminate technical information that
defines the Internet (rfc* files)
5. Some FTP Command meanings:
quit Close connection to the remote host, stop the ftp program
? or help Display a list of all ftp commands
? <ftp command> Display a one-line summary of the specified command
help <ftp command>
! Local host: pause ftp and start a shell
! <Unix Command> Local host: pause ftp and execute that Unix command
Connecting:
open <hostname> Establish connection to the specified computer
close Close the connection to the remote host, stay in the ftp program
user [name [password] ] set user name for ftp session
Directories:
cd <directory> Remote host: change to the specified directory
cdup Remote host: change to the parent directory
dir [directory [file] ] Remote host: display a long directory listing
lcd [directory] Local host: change directory
ls [directory [file] ] Remote host: display a short directory listing
pwd Remote host: display the current directory name
Transferring Files:
get [remotefile [localfile] ] Download one file from remote host, no wildcards
mget [remotefiles ] Download multiple files from remote host, wildcards ok
put [localfile [remotefile] ] Upload one file from remote host, no wildcards
mput [localfiles ] Upload multiple files from remote host, wildcards ok
Setting Options:
ascii Set file type to ASCII text file
(default)
binary Set file type to binary file (do this
if not sure)
hash Yes/No: show # for each data
block transferred
prompt Yes/No: prompt for multiple file
transfers
status Display current status of options
6. Notes about ftp commands
* To stop an ftp command as it is executing, press <CTRL-C>
* To run a UNIX command while under ftp control, type !command or
! to get multiple commands
* To display text files to the terminal (rather than download into a file)
ftp> get readme.txt -
* Browse any size text files within ftp (a screenful at a time)
ftp> get readme.txt |more
* Browse a directory within ftp (a screenful at a time)
ftp> get . |more
* Different File types: Suffix file.Z Compressed file (use $ uncompress file.Z)
Suffix file.tar Archive file (use $ tar -xvf file.tar to extract)
use $ tar -tvf file.tar
to view contents)
Suffix file.txt text file
README General information about this directory
index A description of each file in the directory
ls-lR.Z A file having a long list, sorted alphabetically
ls-ltR.Z A file having a long list, sorted by latest file first
* It is possible to create a Unix Script that calls ftp and
downloads based on a data file of ftp commands. Such a
script can run unattended and can be prescheduled using the at command
7. Requesting (Anonymous) ftp by mail (64000 bytes at a time)
* Use a program called ftpmail to mail a request to an ftpmail server.
$ mail ftpmail.decwrl.dec.com #in California
[16.1.0.1]; or
$ mail bitftp@pucc.princeton.edu #via bitnet
[128.112.129.99]
Subject: Requesting a text file
reply arkay@hcc-cis.ctc.edu
connect cathouse.org <username> <password> <account>
ascii
chdir /misc/fun/humor/british.humour/monty.python/flying.circus
get argument.clinic
quit
<Ctrl-D>
EOT
* Selected Commands
Specifying your E-mail address:
reply <E-mail Address> mail response
Connect to the Host:
connect <host> Connect to specified
Anonymous FTP host
Setting options:
ascii Files to be mailed are text
files
binary Files to be mailed are
non-text or text
files
uuencode convert binary files to
text using uuencode
btoa convert binary files to text
using btoa
Specifying the directory:
chdir <directory> Change to the
indicated directory
Requesting Files:
get <file> Download file (up to 10
gets per ftpmail
message)
Requesting Information:
help Send and describe
how to use ftpmail
dir [ directory ] Send a long directory
listing
ls [ directory ] Send a short directory
listing
Ending the Session:
quit Terminate the session,
ignore the rest
of message.
Questions? Robert Katz: katz@ned.highline.edu
Last Update December 7, 1999