LESSON 5.0.0: Introduction to File Transfer


5.0.0 Objectives
5.0.1 What is FTP?
5.0.2 Names of Some of the FTP Commands
5.0.3 Anonymous FTP Sites
5.0.4 Anonymous FTP
5.0.5 Arrangement of Files in Host Computers
5.0.6 Sending Files to Other Computers via FTP

5.0.0 OBJECTIVE

Lesson 5.0.0 "Introduction to File Transfer, FTP" will provide basic information about the file transfer method known as FTP. This lesson will explain how FTP works and will list additional sources of information. The next assignment focuses on the steps for conducting file transfer via FTP.

5.0.1 WHAT IS FTP?

FTP stands for "file transfer protocol." FTP is a software program that permits copies of files to be made and transferred between two different computers, anywhere in the world. ASCII (text files) or binary (image, sound, and program files) may be transferred via FTP. If your computer or the computer where you have your account has FTP software, it can get files from other computers that have FTP software. There are two types of FTP: anonymous FTP for publicly available files and FTP between hosts where the user has access privileges.

The FTP protocol is designed to allow transferring data between hosts that use dissimilar file systems. Therefore, although the protocol provides a lot of flexibility for transferring data, it does not attempt to preserve file attributes that are specific to a particular file system (for example, the protection mode or modification times of a file). Additionally, the FTP protocol makes few assumptions about the overall structure of a file system and does not provide or allow such things as recursively copying subdirectories.

The ftp command provides subcommands for tasks such as listing remote directories, changing the current local and remote directory, transferring multiple files in a single request, creating and removing directories, and escaping to the local shell to perform shell commands. The ftp command also provides for security by sending passwords to the remote host and permits automatic login, file transfer, and logoff.

If you execute ftp and do not specify a hostname, ftp immediately displays the ftp> prompt and waits for an ftp subcommand. To connect to a remote host, you then execute the open subcommand. When the ftp command connects to the remote host, ftp then prompts for the username and password before displaying the ftp> prompt again. FTP fails if no password is defined at the remote host for the specified username.

If you do specify the name of a remote host, ftp immediately tries to establish a connection to the specified host. If ftp connects successfully, ftp prompts you for a username and password. Once ftp completes the login process, ftp then displays the ftp> prompt and waits for a subcommand.

5.0.2 NAMES OF SOME OF THE FTP COMMANDS

ascii
Sets the file transfer type to network ASCII. This ftp command is the default when ftp cannot determine that the remote system is a UNIX system. File transfer may be more efficient with binary-image transfer.
bell
Sounds a bell after the completion of each file transfer.
binary
Sets the file transfer type to binary image, by default, if ftp can determine that the remote system is a UNIX system. This can be more efficient than an ASCII transfer.
bye
Ends the File Transfer session and exits ftp. Same as quit.
case
Sets a toggle for the case of filenames. When case is on, remote filenamesthat appear in all capital letters are changed from uppercase to lowercase when written in the local directory. The default is off (uppercase remote filenames are written in uppercase in the local directory).
cd remote_directory
Changes the remote working directory to the specified directory.
cdup
Changes the working directory on the remote host to the parent of the current directory.
close
Ends the File Transfer session, but does not exit ftp. Defined macros are erased. Sameas disconnect.
cr
Strips the carriage-return character from a carriage-return /linefeed sequence when receiving records during ASCII-type file transfers. (ftp terminates each ASCII-type record with a carriage-return/linefeed sequence during file transfers.) This conforms with the OSF/1 and UNIX system convention for terminating records with a single linefeed. Records on remote hosts that have different record termination conventions may have single linefeeds imbeded in records. To distinguish these imbeded linefeeds from record delimiters, set cr to off cr toggles between on and off.
delete remote_file
Deletes the specified remote file if you have rights on that server to delete a file.
dir [remote_directory][local_file]
Writes a listing of the contents of remote_directory to the file local_file. If remote_directory is not specified, dir lists the contents of the current remote directory. If local_file is not specified or is a - (dash), dir displays the listing on the local terminal.
disconnect
See close.
form format
Specifies the form of the file transfer. The only format available is non-print.
get remote_file [local_file]
Copies the remote file to the local host. If local_file is not specified, the remote filename is used locally and is altered by any settings made by the case, ntrans, and nmap subcommands. The ftp command uses the current settings for type, form, mode, and struct while transferring the file. For additional information, refer to the description of each of these subcommands.
help [subcommand]
Displays help information. Refer to the ? subcommand.
ls [remote_directory] [local_file]
Writes an abbreviated file listing of a remote directory to a local file. If remote_directory is not specified, ftp lists the current remote directory. If local_file is not specified or is a - (dash), ftp displays the listing on the local terminal.
mget remote_file
Expands remote_files at the remote host and copies the indicated remote files to the current directory on the local host. Refer to the glob subcommand for more information on filename expansion. The remote filenames are used locally and are altered by any settings made by the case, ntrans, and nmap subcommands. The ftp command uses the current settings for type, form, mode, and structure while transferring the files. Refer to the description of each of these subcommands for additional information.
mkdir [remote_directory]
Creates the directory remote_directory on the remote host only if you are authorized.
put local_file [remote_file]
Stores a local file on the remote host. If you do not specify remote_file, ftp uses the local filename to name the remote file, and the remote filename is altered by any settings made by the ntrans and nmap subcommands. The ftp command uses the current settings for type, form, mode, and structure while transferring the files. Refer to the description of each subcommand for additional information.
pwd
Displays the name of the current directory on the remote host.
quit
Ends the file transfer session and exits ftp. A synonym for bye.

Aborting a File Transfer

To abort a file transfer, use the Interrupt key sequence (often [Ctrl-c]). Sending and receiving transfers are immediately halted.

When using FTP with your Unix account, files that you transfer in (get) will be saved on "raider". To view a listing of files use "ls -l" or "ls -al" (to include listing of files starting with a "." dot).

5.0.3 ANONYMOUS FTP SITES

Some Internet sites (organizations, institutions, or others that make their computers accessible on the Internet) also make files available to the public through "anonymous FTP". Host computers that permit anonymous FTP contain archives of files that can be transferred to your Unix account. These archives are sometimes called FTP Sites. There are hundreds of such FTP Sites and typical file types available through anonymous FTP include:

5.0.4 ANONYMOUS FTP

Anonymous FTP sites that provided files for public access via FTP are often referred to as host computers. Such hosts usually require a "logon" and "password" (much like when logging on to your Unix account). A host that permits anonymous FTP will let anyone logon with the set of conventions known as "anonymous FTP".

In anonymous FTP, when the host computer asks for a logon the response is "anonymous" and the password is your own Internet e-mail address. For example:

LOGON> anonymous


PASSWORD> yourLoginName@raider.grcc.cc.mi.us

Responding "anonymous" to the logon prompt tells the host that you are not on its list of registered users. Responding to the password prompt with your Internet e-mail address merely serves as a convention that allows system administrators to track who is accessing the public area of their sites. (Often the password response you make will not appear on the screen to keep the password confidential.)

NOTE: If you use the Windows WS_FTP client all you need to do is check the Anonymous Login box and WS_FTP will fill in the login name, anonymous, and password, guest. Guest seems to work on most "anonymous FTP" sites.

5.0.5 THE ARRANGEMENT OF FILES IN HOST COMPUTERS

Files at FTP sites on host computers are usually arranged in "directories" and "subdirectories", similar to the DOS filing system.

To transfer a file via FTP, it is necessary to first move into the directory on the host computer where the desired file is stored. Once connected to the host computer the command