自动从ftp下载文件(不回显输入密码)

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>



#!/usr/bin/perl 
#===============================================================================
#
#         FILE:  autoftp.pl
#
#        USAGE:  ./autoftp.pl  
#
#  DESCRIPTION:  Download data from ftp automatically
#
#      OPTIONS:  ---
# REQUIREMENTS:  ---
#         BUGS:  ---
#        NOTES:  ---
#       AUTHOR:  Will
#      COMPANY:  CNNDC 
#      VERSION:  1.0
#      CREATED:  11/18/2010 03:06:49 AM
#     REVISION:  ---
#===============================================================================

# use strict;
use warnings;
use Net::FTP;
use Term::ReadKey;

die "Usage:\n\t$0  [user]\@Server:file\n" if (!scalar @ARGV);
my ($user, $password, $server, $file) = qw#anonymous anonymous@mail#;
my $debug=0;

($server, $file) = $ARGV[0] =~ /\@?([\w\d]+):([\w\W]+)/;
if ( $ARGV[0] =~ /([\w\W]+)\@/ ) {
	$user = $1;	
	print "Input password: ";
	ReadMode 2;
	chomp($password=<STDIN>);
	ReadMode 0;
}
# print "$user, $password, $server, $file\n";

my $ftp = Net::FTP->new("$server", Debug => $debug) 
	or die "Can NOT connect to $server. $@";
$ftp->login("$user", "$password") 
	or die "Can NOT loggin. ", $ftp->message;
$ftp->binary()
	or die "Can NOT set binary mode. ", $ftp->message;
$ftp->get("$file") 
	or die "get $file failed. ", $ftp->message;
$ftp->quit;