Operating System - HP-UX
1834432 Members
2455 Online
110067 Solutions
New Discussion

Re: ftp transferred file types

 
SOLVED
Go to solution
Shivkumar
Super Advisor

ftp transferred file types

Hi,

Some files has been transferred using ftp by someone. I need to verify whether files were transferred in binary or ascii mode.

Can anyone suggest how to verify ?

Thanks,
Shiv
3 REPLIES 3
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: ftp transferred file types

It can sometimes be difficult to tell. The real difference is text files. On DOS/Windows boxes each line of text ends with a Carriage Return (CR - ASCII 0x0d), Linefeed (LF - ACSII 0x0a) pair whereas a UNIX text file ends with simply a LF.

Consider, transferring a Windows text file to UNIX in ASCII, in that case, each line of text is read and the CRLF pair is stripped off and replaced with a single LF.
(This is exactly what the dos2ux command does as well).

If the files are exactly the same size on both machines then almost certainly a binary transfer was done but, for example, if doing the above ASCII transfer of a text file from a Windows box to a UNIX but the Windows file simply had LF's on each line then an ASCII transfer would also be identical.

In short, without knowing the format of a given file before it was transferred; it is not possible to say WITH CERTAINTY how it was transferred. You can use od or xd to examine a file and display non-ASCII characters. Man od or xd for details.

By far, the wisest course, is to assert the actual transfer type using either the "ASCII" or "binary" ftp command before ever starting a file transfer. The default transfer mode is normally negotiated upon connecting the ftp client with the ftpd daemon.

If it ain't broke, I can fix that.
Yogeeraj_1
Honored Contributor

Re: ftp transferred file types

hi shiv,

this may be possible only if your server has been configured to enable logging of FTP transactions.

the xferlog thereby generated will provide the required information. The format of the information logged is as follows:
(a single line with all fields being separated by spaces)
current-time
transfer-time
remote-host
file-size
filename
transfer-type
special-action-flag
direction
access-mode
username
service-name
authentication-method
authenticated-user-id
current-time-in-seconds

You will be interested in the following field:
transfer-type
A single character indicating the type of transfer which can be one of:
a for an ascii transfer
b for a binary transfer


hope this helps!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
inventsekar_1
Respected Contributor

Re: ftp transferred file types

HI SHivkumar,
to enable FTP logging in widows,
http://www.windowsecurity.com/pages/article_p.asp?id=1251
To enable FTP lgging in HP-UX,
see the attachement "Installing and Administering Internet Services"
page number 51
and:
http://docs.hp.com/en/B2355-90778/ch02s01.html

more info:
man ftpaccess
man 1m ftpd
Be Tomorrow, Today.