标题: perl写了个ftp传输脚本,老是中断,请大虾指导。 [打印本页] 作者: xuqing1980119 时间: 2016-11-02 10:36 标题: perl写了个ftp传输脚本,老是中断,请大虾指导。 #!/usr/bin/perl
#use strict;
use Net::FTP;
use File::Find;
my $uploadpath = "/data01"; #上传的路径
my $datapath = "/xddr/timeing/bak/201610/20161001"; #要上传的文件的本地路径
my $host="134.1.169.120";
# get file list to be upload
find( \&filter, $datapath);
my $ftp=Net::FTP->new($host,Passive => 1) or die "cannot connect to ftp server $!";
$ftp->login("test","test");
$ftp->binary and print "set type to binary\n";
$ftp->cwd($uploadpath);
foreach $file (@filelist) {
my $result = $ftp->put($file);
}
$ftp->quit();
@filelist=();
sub filter{
push @filelist, $File::Find::name if -f ;
}