|
sub download{
my $ftp = Net::FTP->new("$_[0]",Timeout => 5,Passive => 0) or die "Can't connect to the Ftp :$@\n";
$ftp->login("$config{ftp_user}","$config{ftp_pass}") or die "Can't login . ",$ftp->message;
$ftp->binary or die "Cannot change binary mode ", $ftp->message;
printcolor bold,"\nInput the subdir:\n";
printcolor blue,"$config{ftp_host}:$config{ftp_root_dir}/";
chomp($ftp_sub_dir=);
$ftp->cwd("$config{ftp_root_dir}/$ftp_sub_dir") or die "Change File:",$ftp->message;
printcolor green,"Change Dir Success!\n";
printcolor bold,"Input the filename:";
chomp($down_file=);
printcolor blue,"\nDownloading...Please Wait.\n";
$ftp->get("$down_file","$config{local_dir}/$down_file") or die "Can't get the $down_file . ",$ftp->message;
printcolor green,"+++ Download Success! +++\n\nMD5: ";
$ftp->quit;
open L_FILE,"$config{local_dir}/$down_file";
printcolor yellow,Digest::MD5->new->addfile(L_FILE)->hexdigest,"\t$config{local_dir}/$down_file\n\n" ;
close L_FILE;
}
|
|
|