|
楼主 |
发表于 2006-9-11 15:50:51
|
显示全部楼层
#!/usr/bin/perl -w
use strict;
use Net::FTP;
my $serverip = "192.168.4.11";
my $svrftpdir = "/home/ftptest";
my $svrftpgetdir = "$svrftpdir/get";
my $tmpcasedir = "/tmp/tmpcase";
main();
sub main
{
do_ftpget();
}
sub do_ftpget
{
chdir($tmpcasedir);
my $ftp = Net::FTP->new("$serverip", Debug => 0)or die "Cannot connect to $serverip: $@";
$ftp->login("ftptest",'123456')or die "Cannot login ", $ftp->message;
$ftp->cwd("$svrftpgetdir") or die "Cannot change working directory ", $ftp->message;
my @caseboxlist = $ftp->ls("$svrftpgetdir");
foreach my $casebox(@caseboxlist)
{
chomp($casebox);
if(-d "$casebox")
{
$ftp->cwd("$casebox") or die "Cannot change working directory ", $ftp->message;
my @caselist = $ftp->ls("$casebox");
print $casebox;
foreach my $casename(@caselist)
{
chomp($casename);
if(-d "$casename")
{
$ftp->cwd("$casename")or die "Cannot change working directory ", $ftp->message;
my @getcaselist =$ftp->ls("$casename");
foreach my $getcasename(@getcaselist)
{
$ftp->get("$getcasename")or die "get failed ", $ftp->message;
}
}
elsif(-f "$casename")
{
$ftp->get("$casename")or die "get failed ", $ftp->message;
}
}
}
elsif(-f "$casebox")
{
$ftp->get("$casebox")or die "get failed ", $ftp->message;
}
}
}
这是我的脚本,为什么还是get不到文件,请问错再哪里,谢谢! |
|