FTP "Ascii" Vs "Binary" Mode -- What It Means, and Why You Want to Use One or the Other (taken from Support Newsletter 32 June 1998)
search cancel

FTP "Ascii" Vs "Binary" Mode -- What It Means, and Why You Want to Use One or the Other (taken from Support Newsletter 32 June 1998)

book

Article ID: 28212

calendar_today

Updated On:

Products

Activator eTrust ALERT eTrust ALERT for CICS ALERT Archiver ASM/ARCHIVE VSE-ESA OPTION ASM/Archive AutoAction AutoSys Job Management Adapter for AutoXfer Process Automation Manager Portal ARCserve Backup Client CICSORT Clipper COBOLVISION Analyzer CTO Distributed Dart Datesolver/2000 Distribulink EUREKA:Object EPIC VM Enterprise Endevor for Unix Archiver Disk Option EPIC Backup EPIC Access Option EPIC SUPER SYS EPIC for CMS System EPIC TAPE MANAGEMENT eTrust Antivirus Gateway for CVP eTrust Content Inspection Gateway eTrust Content Inspection Gateway Option for MSP/ISA EE eTrust Antivirus Gateway for Netscape eTrust VPN Enterprise Edition FAQS VM FAQS Automated Systems Operation Global Subsystem (GSS) ANDYNE MAINFRAME MISCELLANEOUS Inventory Discovery Server ARS Resource Management JARS Resource Management ACC Option JOBDOC JOBWATCH Look MAZDAMON Service Management Affiliate Technology Partner Fee Service Management Basic Technology Partner Fee Metanet MF - MISC OLD CODES Omniguard for CICS Omniguard Opera Connect PREVAIL Paramount XP CAM FOR DIST SYS Paramount FOR NAVIGRAPH/HOST Research Planmacs Unlimited Project Planner Remote Console PREVAIL/XP-AUTOMATION PHASE 1 Remote Console PREVAIL/XP AUTOMATION-RDF/SSM Raps Research Raveler Generic Non Product SOLVE:EPS Unicenter NetMaster Network Management for SNA Alexandria Sort System SPOOLMAN Storage Mainframe SYSTEM/SCHEDULER SYSTEM/SCHEDULER VSE-ESA OPTION System/Manager Tape/Manager VSE-ESA OPTION Output Management Document Server TNG Network and Systems Management Agent for CA-Datacom DFSMShsm Workstation Network and Systems Management UNIX SMTP Unicenter Management for Microsoft Exchange SMTP Option UNICENTER II Unicenter Network and Systems Management Database Performance Monitor Option UNICENTER OSM Database Command Center Mnt VM:DBA VM:DB Admin VM:DB Center VM:DB Developer VM:DB Editor VM:DB Monitor VM:DB Reorganizer VM:DB Reporter VM:DB Restore VM:DB REXX VM:DB SQLMAP VM:DB Suite VM:Migrate VM:Monitor VM:Notekeeper V/Solver VM:Webserver for Officevision VM:Webserver Secure VM:Webgateway VM:Webserver XMENU for z/VM VISION:COMBO for TSO VISION:DAGER VISION:ELEVEN VISION:EIGHTY VISION:Online VISION:IQ for Informix Automate

Issue/Introduction

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.

Additionally, everyone should remember that since our ftp site is an NT server, the default transfer mode is ascii. Our typical customer is a UNIX sys admin. They are used to sites that default to binary. When asking them to put files on our site, remind them that it defaults to ascii and that they will want to set binary mode.

Environment

Release:
Component: ALEX