Why am I getting “File not found” errors with this Perl script using Net::FTP?

左心房为你撑大大i 提交于 2019-12-13 03:23:49

问题


Can anybody tell me what is wrong with this code?

As far as concern about as I know @zipFiles = grep /zip/, $ftp->dir; is creating a prob but if I will remove this part then I will not have any thing for using regex part.

Error : <"Time, file_created_date, File_size, File_name"> file is not found.

use Net::FTP;

#use File::Copy;

$Login   = "<redacted>";
$Pwd     = "<redacted>";
$ftpHost = "<redacted>";

$ftpFolder = "/daj/dhakj/ahdakl/abc_201206_def_05";
$ftp = Net::FTP->new( $ftpHost, Timeout => 100 );

if ($ftp) {
    print $ftp->message;
}

$ftp->login( $Login, $Pwd );
print $ftp->message;
$ftp->cwd($ftpFolder);
@all_dir = $ftp->ls();

#print @all_dir;

foreach $ls_dir (@all_dir) {
    if ( $ls_dir !~ /exe|txt|zip/ ) {
        $latest_dir = $ls_dir;
    }
}

print "$latest_dir\n";
$mcl_dir = '/daj/dhakj/ahdakl/abc_201206_def_05' . $latest_dir;
$ftp->cwd($mcl_dir) or die "not able to change the dir\n\n";
@zipFiles = grep /zip/, $ftp->dir;

foreach my $myfile (@zipFiles) {
    if ( $myfile !~ /a|b|c|d|/g ) {
        $ftp->get("$myfile");
        print $ftp->message;
    }
}

来源:https://stackoverflow.com/questions/9348978/why-am-i-getting-file-not-found-errors-with-this-perl-script-using-netftp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!