我正在使用此Perl压缩文件,以便我的报告服务器可以在凌晨4点通过计划任务下载它。
my $now = defined $_[0] ? $_[0] : time;
#my $then = $now; #today date
my $then = $now - 60 * 60 * 24*0; #show 1 month ago day
my $ndst = (localtime $now)[8] > 0;
my $tdst = (localtime $then)[8] > 0;
$then - ($tdst - $ndst) * 60 * 60;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($then);
my $today2 =($year+1900).substr("0".($mon+1),-2,2).substr("0".$mday,-2,2);
my $today =($year+1900)."-".substr("0".($mon+1),-2,2)."-".substr("0".$mday,-2,2);
my $password="ch1ngk3nb3rs1h";
my $outwhere ="C:\\Vasboss\Logs";
my $wheretrans="C:\\VASBoss\\RunMe\\OMO_newuser\\testupdate\\";
print "$cmd\n";
$cmd="\"C:\\Program Files (x86)\\WinRAR\\Rar.exe\""." a -ep -p$passwordresupdate-$today2.rar $outwhere"."resupdate-$today2.rar \"$wheretrans$filter\\resupdate-$today2.txt\"";
$pid2=system($cmd);
此命令目前适用于Windows。 所以我已经翻译成Linux但无法工作。
my $now = defined $_[0] ? $_[0] : time;
#my $then = $now; #today date
my $then = $now - 60 * 60 * 24*0; #show 1 month ago day
my $ndst = (localtime $now)[8] > 0;
my $tdst = (localtime $then)[8] > 0;
$then - ($tdst - $ndst) * 60 * 60;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($then);
my $today2 =($year+1900).substr("0".($mon+1),-2,2).substr("0".$mday,-2,2);
my $today =($year+1900)."-".substr("0".($mon+1),-2,2)."-".substr("0".$mday,-2,2);
# my $today = "2013-12-29";
my $password="ch1ngk3nb3rs1h";
my $outwhere ="/frenclubsosial/report/jeeva/live";
my $wheretrans="/frenclubsosial/report/";
print "$cmd\n";
$cmd="zip $passwordresupdate-$today2.zip $outwhere"."resupdate-$today2.zip \"$wheretrans$filter\\resupdate-$today2.txt\"";
$pid2=system($cmd);
但我无法运行Perl脚本。
我得到的错误是:
sh: 1: zip: not found