General
cancel
Showing results for 
Search instead for 
Did you mean: 

calculatinf file size during FTP from windows to unix server

Jag14
Occasional Contributor

calculatinf file size during FTP from windows to unix server

Hi,
can Anyone tell me what is the syntax to get the size of the file before and after FTP.

I am FTPing from windox box to unix box....
3 REPLIES
kobylka
Valued Contributor

Re: calculatinf file size during FTP from windows to unix server

Hello Jag14!


You can use "ls -l" or "dir" on Windows clients to see size file in bytes. You could also use the "raw" command to send this request for a given file:

quote size file_name

It will return 2 numbers, the first is the ftp reply code, the second the size in bytes.


After you downloaded the file use "ls -l file_name" or "du -ks file_name" to see the size of the file.


Kind regards,

Kobylka
Matti_Kurkela
Honored Contributor

Re: calculatinf file size during FTP from windows to unix server

As this is a HP-UX group, I assume you're using a HP-UX FTP client to get files from Windows FTP server.

Use the "dir" command in the FTP client to see the remote directory listing in a form that usually includes the file size.

Or use the "size " FTP command: the response should be the result code 213 and the size of the remote file, like this:

213

To see the size of a local file, use the normal command-line "ls -l" or "ll" commands, but prefix them with an exclamation sign:

!ls -l

If you're running a command-line based FTP client on a Windows host, accessing a HP-UX server, there are a few differences:

1.) use the "!dir " to see the size of a local file, as "ls" is not a valid command for the Windows command prompt.

2.) the Windows command-line FTP client may not understand the "size" command. Fortunately the command is so simple you don't need the FTP client to interpret its output. You can use "quote size " to send the command directly to the server, bypassing any client-side validity checks.

If you transfer files in binary mode, the file size (and the file content) should not change at all.

If you transfer text files in ASCII mode, find out the number of lines in the file ("wc -l " in Unix).

The ASCII mode translates one-byte Unix line terminators to two-byte Windows line terminators or vice versa. So the text file should grow in size by one byte per line when transferred from Unix to Windows, or shrink the same amount if transferred from Windows to Unix.

If you transfer a file that contains any non-ASCII characters using the ASCII mode of FTP, the file will most likely be corrupted in transit. Don't do it. Use the binary mode instead, and use a proper tool for character set conversion.

MK
MK
OldSchool
Honored Contributor

Re: calculatinf file size during FTP from windows to unix server

a problem will arise if the files are plain-text and transferred in ascii mode. fpt should convert the unix end-of-line to windows end-of-line, one is CR, the other is CR/LF. I believe windows is the later. In either case, the size or the transferred file will differ by one byte per line of text in the original.

I assume you're looking at this to check the validity of the file once transferred? If that's the case, it won't work, at least for text files. Neither will checksumming, for similar reasons.

If you need to be 100% sure the file made it, and isn't damaged or corrupted in some fashion, you may need to look at something other that FTP as the transfer mechanism.