There are two different modes for transferring files with FTP: “ASCII” and “binary” mode. The reason for the two different modes is that there are two distinct means of representing the end of a line in a text, or ASCII, file. On UNIX machines, the end of a line is represented by the character. This character is a control-J. Some UNIX commands, like od(1), represent this character with a “\n”. For example, if you have a UNIX file named “foo”:
$ cat foo this is a test of the terminal that is shot from guns. $ od -c foo 00000000000 t h i s i s a t e s t o 00000000020 f \n t h e t e r m i n a l t 00000000040 h a t i s \n s h o t f r o m 00000000060 g u n s . \n 00000000067
On PCs (and on Mainframe computers) the end of a line is represented by a <carriage return> followed by a <newline> character. This is a control-M followed by a control-J.
In FTP, if you specify “ASCII” mode, if you are sending a file from a UNIX system to a PC, a control-M will be added before every control-J in the file. This will ensure that the ASCII/text file will be readable on the PC. Conversely, if you send a file in “ASCII” mode from a PC to a UNIX system, the combination control-M control-J will get changed into a control-J. File size will decrease by one byte per line when sending from a PC to a UNIX system; file size will increase by one byte per line when sending from a UNIX system to a PC. When sending between two PCs — or two UNIX systems — files send in “ASCII” mode will be unchanged.
Files sent in “binary” mode are sent from one system to another with no modification. The file size will always be unchanged on a binary transfer.
“ASCII” mode is appropriate when using FTP to send a single text file between two PCs. “binary” mode is appropriate when sending anything else: TAR files, compressed files, gzip’d files, CA-Alexandria binaries, etc. If a binary file is sent between a PC and a UNIX system in “ASCII” mode, the contents of the binary file will be modified such that it will no longer be readable; the file will have to be re-sent from the originating system in binary mode. Typically, this is the source of the problem when a customer sends us TAR or compressed files that are not readable on our machines.