我正在尝试使用网址从远程服务器获取文件。
CODE:
use File::Fetch;
use strict;
my $url = 'http://***********/all-bin/ASNvx14173/JAKASUSI_BUP_IIR009.doc';
$ENV{HTTP_proxy}=$proxy_url;
my $ff = File::Fetch->new(uri => $url);
my $where = $ff->fetch(to => "/temp");
my $file = $ff->file;
my $error=$ff->error();
print "result=$error\n";
print "Error==>$url==>$error\n";
if($error){
$logger->error("Not fetching attachments!! - $error\n FILE $id : $url\n");
}
next if ( $error ne "" );
delete $ENV{HTTP_proxy};
错误
Fetch failed! HTTP response: 503 Service Unavailable [503 Service Unavailable] at ./bin/convert_to_csv.pl line 911 thread 1.
Fetch failed! HTTP response: 503 [Service Unavailable] at ./bin/convert_to_csv.pl line 911 thread 1.
我无法处理此错误。以及如何设置要获取的特定文件的超时?请帮我解决这个问题。
答案 0 :(得分:0)
This page包含File :: Fetch的文档。
请看this。
成功时返回下载文件的完整路径,并返回false 故障。
您需要检查错误的位置以查看是否存在问题。
my $where = $ff->fetch(to => "/temp");
if ( !$where ) {
my $error=$ff->error();
print "result=$error\n";
print "Error==>$url==>$error\n";
$logger->error("Not fetching attachments!! - $error\n FILE $id : $url\n");
}
else {
my $file = $ff->file;
# do stuff with file
}
同样this说明将TIMEOUT设置为一个值。 $File::Fetch::TIMEOUT = $value_in_seconds;