0

我正在运行一个 perl 脚本,该脚本从 ftp 服务器获取文件,然后执行系统命令。

当我从调度程序运行任务时,它不会抓取文件,但会执行系统命令。两者都包含在 if 语句中,所以我知道 if 语句工作正常。

我已经检查了权限,并且任务正在使用最高权限。我也以管理员身份运行该任务。现在,问题是当我手动运行程序时,一切正常。为什么当我手动运行它时它可以正常运行,但当我通过调度程序运行它时却不能?

这是一些代码:

if ($size_ftp == $size_local) {
            print "Files are the same...\n";
            $ftp->quit;
            print "FTP has quit!\n";
        } else {
            print "Files are not the same...begin download!\n";
            $ftp->get($file_ftp) or die "get failed ", $ftp->message;
            print "Download complete...\n";
            $ftp->quit;
            print "FTP has quit!\n";
            my $Archive_file = Archive::Extract -> new( archive => $file_dir );
            print "File extraction identified...\n";
            $Archive_file -> extract( to => $extract_here );
            print "File extracted...\n";
            system('call "C:\QMSEDX.exe"');
            print "System EDX call completed!\n";
    }
4

1 回答 1

2

为什么你认为文件没有下载?你有“失败”的错误吗?我确定它已下载但未下载到您想要的位置。

当您的脚本从调度程序执行时,当前工作目录通常与您从命令行运行它的目录不同。您可以在任务的属性中设置脚本工作目录,也可以告诉脚本将下载文件保存在哪里

use FindBin qw($Bin);

....

$ftp->get( $file_ftp, "$Bin/$file_ftp" ) or die "get failed ", $ftp->message;
于 2013-05-29T00:28:11.780 回答