[comp.misc] what does ascii ftp do to a binary file?

gwoho@nntp-server.caltech.edu (g liu) (12/07/90)

what happends  to a binary file when it is sent by ftp in ascii mode?
it seems to me that some bytes are removed, and that's all. what exacly
happens? (i am interested in fixing some files send wrong)
gwoho liu

gwoho@nntp-server.caltech.edu (g liu) (12/07/90)

gwoho@nntp-server.caltech.edu (g liu) writes:

>what happends  to a binary file when it is sent by ftp in ascii mode?
>it seems to me that some bytes are removed, and that's all. what exacly
>happens? (i am interested in fixing some files send wrong)
>gwoho liu
i tried ftping some binary files around in ascii mode.
i discovered: going from machine a to machine b, nothing happens to the file.
going from machine b to machine a, the file increased by about 3k.
ftp reported receiving about 7k extra, but the file turned out to be only 3k
extra. (the number of bytes ftp reported receiving doesn't match the
number of bytes  in the file i got).
i sent the file twice. both times, exactly the same thing happened to the file.
what's happening? why is ftp reporting an inacurate size?
gwoho liu.

barmar@think.com (Barry Margolin) (12/07/90)

When a file is sent in ascii mode, whatever character sequence represents
line end in text files on the sending system will be tranformed to carriage
return (13) followed by line feed (10) during transmission.  In addition,
any carriage returns in the original file (if they aren't part of the line
end sequence) will be transformed to carriage return followed by null (0).

The receiving system will tranform any CR followed by LF into its
representation of a line end, and CR followed by NUL into CR.

If the two systems run the same operating system these two transformations
should be perfect inverses (except for the case described below).  If not,
irreversible transformations may occur.

Finally, if either of the systems normally stores text files using some
code other than ASCII (e.g. if one of the systems is an IBM mainframe,
most of which use EBCDIC), it will translate between its native character
code and ASCII.  Since different character code sets may support different
characters, some characters may get lost in the translation.
--
Barry Margolin, Thinking Machines Corp.

barmar@think.com
{uunet,harvard}!think!barmar

ts@uwasa.fi (Timo Salmi) (12/07/90)

In article <1990Dec6.194811.7643@nntp-server.caltech.edu> gwoho@nntp-server.caltech.edu (g liu) writes:
>what happends  to a binary file when it is sent by ftp in ascii mode?
>it seems to me that some bytes are removed, and that's all. what exacly
>happens? (i am interested in fixing some files send wrong)

Let me make an obvious suggestion.  Use any suitable filedump
program to compare a file sent as binary and as ascii.  That way you
can be sure on the answer on your own configuration. 

...................................................................
Prof. Timo Salmi        (Moderating at anon. ftp site 128.214.12.3)
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: gado::salmi Bitnet: salmi@finfun

ken@csis.dit.csiro.au (Ken Yap) (12/10/90)

In article <1990Dec7.085559.1537@Think.COM>:
>[A good explanation of the transformations used in ftp]
>Barry Margolin, Thinking Machines Corp.

Also note that one is not guaranteed that a binary file will be read
properly while in ascii mode on the SENDING machine.  Simtel20, a
TOPS-20 machine, for example, would not allow you to fetch a binary
file in ascii mode.  So it may not be be possible to recover the file
intact even after cleaning.

Having said that, I confess to using binary mode for all files when I
know the other machine is a Unix box, like mine.