Unless the ftp server provides the md5 hashes, I don't think there's any way you can create them on the server (which is really what you're talking about). If the files aren't too large, and you really want to be sure about their integrity, you could pull each file twice. You would still want to compare the file size to the size on the server. That check combined with a the comparison of multiple downloaded files should be pretty reliable. | [reply] |
Does the remote server provide such a checksum, perhaps as a similarly named file in the same directory? If so, download that, too, and compare its contents with the checksum that you will generate locally of your downloaded version. If not, is the remote server under your control? If not, can you ask the managers of the remote server to provide such checksums?
For md5, see Digest::MD5
| [reply] |
Bear in mind that checking the md5 hash (and the file size) would be appropriate and meaningful only for "binary mode" ftp transfers, as opposed to "text mode", where LF/CRLF conversion is applied during transfer. Text-mode transfers could systematically change file sizes (by adding or removing CR's next to LF's), depending on the particular server and client in a given transfer.
This is not much of an issue these days -- nearly all ftp transactions are done in binary mode by default now (and usually, ftp tends to be the tool of choice mainly for stuff that is intrinsically non-text). Still, if files are arriving with different sizes than you expect, this is a factor you should check on. | [reply] |
Thanks for your help guys. I guess I'll do the file size
check. And I just discovered that the file will be zips
so I'll also do zip test (unzip -t or if I'll find a module to do it). | [reply] |