例如,如果文件超过给定值(例如2分钟),我会尝试从ftp服务器中删除该文件
我有这样的atm。该脚本可以正常运行,但是应该检查文件的部分不起作用。
到目前为止,我的代码:POST http://TFS2015:8080/tfs/DefaultCollection/{teamproject}/_apis/Release/releases?api-version=2.3-preview.1
{
"definitionId":1,
"description":"",
"artifacts":[
{
"alias":"CAT0604",
"instanceReference":{
"name":"20180621.2",
"id":"57",
"sourceBranch":"$/Scrum-TFVC"
}
}
],
"isDraft":false,
"manualEnvironments":[]
}
dodie:
my $max_time = 120;
if (!&ftp'get($lockkudatei, $Path.$tmpfile, 0)) {
&timedprint("No excisting Lock file");
} else {
my $file_ku_mdtm = $ftp->mdtm($lockkudatei);
if( time - $file_ku_mdtm >= $max_time ) {
if(&ftp'delete("$lockkudatei")) {
&timedprint("Lock file deleted");
} else {
&timedprint("Lock file could not be deleted");
&dodie("Lock file could not be deleted");
}
} else {
&dodie( "No excisting Lock file\n");
}
}
时间表:
sub dodie {
($msg) = @_;
#$t=localtime(time());
#print STDOUT "\nt: $msg";
print STDOUT "\nERROR:$msg";
die( $msg );
}
提前谢谢!
答案 0 :(得分:0)
使用Net :: FTP模块重建脚本,并彻底清除旧代码。现在它可以与模块中的mdtm()一起使用了。
工作正常:
my $file_ku_mdtm = $ftp->mdtm($lockkudatei);
if( time - $file_ku_mdtm >= $max_time ) {}