ftp的fork下载不可以.帮忙看看哪里问题!

ftp的fork下载不可以.帮忙看看哪里问题!

#!/usr/bin/perl

use Net::FTP;
sub ftpdown {
my $user="root";
my $passwd="ftpdown";
my $dates=`date '+%Y%m%d'`;
my $date=$dates-1;
#exec("mkdir -p /file/$date";

my $dirs="/file/$date";
my $haom="192.168";
my $wav=" ->";
my $xxx="xxx";
my $ftp=Net::FTP->new("@_",Port=>21) or die "can't connet@\n";
$ftp->login("$user","$passwd")or die"no login\n";
$ftp->binary;
$ftp->cwd("$dirs")or die "$@\n";
my @filelist=$ftp->dir();
foreach (@filelist){
if ($_ =~ l){
my $start=index($_,$haom);
my $starts=substr($_,$start);
my $ends=index($starts,$wav);
my $localfile=substr($starts,0,$ends);
my $downs=rindex($_,$haom);
my $remotefile=substr($_,$downs);
$ftp->get("$remotefile","$localpath/$localfile");
my $a="list";
print "$a\n";
}
if (!($_ =~ $xxx)){
my $downs=rindex($_,$haom);
my $remotefile=substr($_,$downs);
my $localfile=$remotefile;
$ftp->get("$remotefile","$localpath/$localfile");
}
#print "$_\n",foreach @filelist;

$ftp->quit;
}
}
my @host=("192.168.0.221","192.168.0.224","192.168.0.225","192.168.0.227");
my %pid_to_host;
my $dates=`date '+%Y%m%d'`;
my $date=$dates-1;
if (!(-e "/file/$date")){exec("mkdir -p /file/$date");}
foreach (@host){
if (my $pid=fork){
$pid_to_host{$pid}=$_;
}else{
exit !ftpdown($_);
}
}
while(keys %pid_to_host){
my $pid=wait;
last if $pid <0;
my $host=delete $pid_to_host{$pid},next;
#print "ftp download file is securell\n";

}



各位帮忙看下,为什么这段代码不能下载.如果改成列出@filelist的条目都可以显示!
没有错误讯息???
什么错误信息都没有!


[Copy to clipboard] [ - ]
CODE:
if ($_ =~ l){
my $start=index($_,$haom);
my $starts=substr($_,$start);
my $ends=index($starts,$wav);
my $localfile=substr($starts,0,$ends);
my $downs=rindex($_,$haom);
my $remotefile=substr($_,$downs);
$ftp->get("$remotefile","$localpath/$localfile");
my $a="list";
print "$a\n";
}
if (!($_ =~ $xxx)){
my $downs=rindex($_,$haom);
my $remotefile=substr($_,$downs);
my $localfile=$remotefile;
$ftp->get("$remotefile","$localpath/$localfile");
}

先保证这两个匹配是不是成功吧,是不是能打印点信息出来看下。
最起码 print "$a\n"; 这句打印出来没有。
我能打印出$remotefile ,跟$localfile还有$a都可以打印出来.
在本机器上下载不回来文件!其它的变量都可以打印出来!
192.168.0.224_6765_057487423130_078_20080122094436.wav 192.168.0.224_6765_xxx_078_20080122094436.wav
192.168.0.224_6765_057582188880_078_20080122105750.wav 192.168.0.224_6765_xxx_078_20080122105750.wav
192.168.0.224_6765_057768685444_078_20080122100840.wav 192.168.0.224_6765_xxx_078_20080122100840.wav
192.168.0.224_6765_057768685444_078_20080122101049.wav 192.168.0.224_6765_xxx_078_20080122101049.wav
这个是打印部分($remotefile跟$localfile)
但就是没有看到文件下载回来!
$localpath/$localfile 这个目录你有权限吗?
$ftp->get("$remotefile","$localpath/$localfile");
後面加个
|| die "$@";
可能会出现Error message..