next up previous

3.1.3 Transferring Files     continued...

One of the most important commands is the one that specifies the file transfer mode. FTP recognizes two different types of files, known as binary and ASCII. Binary files are things like compiled programs and large data sets. ASCII files are text files, for example sources of programs and messages posted to newsgroups.

A file transferred in binary mode is copied verbatim, bit for bit, and duplicated exactly on your system as it appeared on the remote system. Use this mode when you copy an executable program or some other file that your system recognizes. For example, if both your workstation and the remote host are Sun workstations, you can probably copy a working program from /bin of the remote host and install it in /bin on your computer and begin using it immediately. Another example is a compressed file, which is a collection of one or more files that has been run through a data compression algorithm. If you have the program that will decompress the file it makes sense to copy it, otherwise it will be useless to you.

Files transferred in ASCII mode are often transformed slightly. FTP knows about the text file formats of common systems and it translates among these formats as it copies a file. For example, lines of text in a source file are separated by a newline character (ASCII code 10) in Unix systems, but on an Apple Macintosh lines end with a carriage return (code 13) and on some systems lines are terminated by a carriage return and line feed combination. You should use ASCII mode when transferring text files because if you use binary mode and you copy a source file between two systems that have different file formats the copy will be unreadable.