Dear Perlers, I made some improvements in my code (now I am checking the file size of remote file) but still can't figure out how to calculate the MD5 hash of a remote file.
Any help is highly appreciated. [code] use strict; use warnings; use Digest::MD5::File qw( file_md5_hex ); use Net::FTP; my $server_name = 'ftp.mysite.com'; my $ftp_username = 'username'; my $ftp_password = 'password'; my $ftp_source_dir = '/public_html/Shaji'; my $ftp_source_image = 'confidence.jpg'; #Located in remote server my $ftp_destination_image = 'confidence.jpg'; my $ftp = Net::FTP->new($server_name, Debug => 1); $ftp->login($ftp_username,$ftp_password); $ftp->cwd($ftp_source_dir); $ftp->binary(); my $remote_file_size = $ftp->size($ftp_source_image); $ftp->get($ftp_source_image, $ftp_destination_image); $ftp->quit; my $local_file_size = -s $ftp_destination_image; print "Remote File Size : $remote_file_size\n"; print "Local File Size : $local_file_size\n"; print "File size identical\n" if $remote_file_size == $local_file_size; #Can't figure out how to calculate the MD5 checksum of remote file #my $md5_source = file_md5_hex( $ftp_source_image ); #my $md5_destination = file_md5_hex( $ftp_destination_image ); #print "MD5 hash is identical\n" if ($md5_source eq $md5_destination); [/code] best, Shaji ------------------------------------------------------------------------------- Your talent is God's gift to you. What you do with it is your gift back to God. ------------------------------------------------------------------------------- On Saturday, 22 February 2014 7:14 PM, Shaji Kalidasan <shajiin...@yahoo.com> wrote: Dear Perlers, I need to download a file from a server using FTP and then I need to compare both files (MD5 Checksum) to ensure that I am testing the right build. Here is the program I have attempted so far. Please throw some light in comparing the MD5 checksum of the source and destination files. [code] use strict; use warnings; use Digest::MD5::File qw( file_md5_hex ); use Net::FTP; my $server_name = 'codeinside.com'; my $ftp_username = 'mx345fg'; #Real username and password changed for security reasons my $ftp_password = 'k*&^%$_(_'; my $ftp_source_dir = '/public_html/Shaji'; my $ftp_source_image = 'confidence.jpg'; #Located in remote server my $ftp_destination_image = 'confidence.jpg'; my $ftp = Net::FTP->new($server_name, Debug => 1); $ftp->login($ftp_username,$ftp_password); $ftp->cwd($ftp_source_dir); $ftp->binary(); $ftp->get($ftp_source_image, $ftp_destination_image); $ftp->quit; my $md5_source = file_md5_hex( $ftp_source_image ); my $md5_destination = file_md5_hex( $ftp_destination_image ); #Need clarification here. Am I doing the right way? print "Files are identical" if ($md5_source eq $md5_destination); [/code] best, Shaji ------------------------------------------------------------------------------- Your talent is God's gift to you. What you do with it is your gift back to God. ------------------------------------------------------------------------------- -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/