Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在perl中使用psftp错误标志_Perl_Putty - Fatal编程技术网

在perl中使用psftp错误标志

在perl中使用psftp错误标志,perl,putty,Perl,Putty,下面的脚本按预期运行。它调用批处理文件,该文件使用PUTTY或特别是psftp建立连接,并传输少量文件。传输完成后,我继续使用perl脚本将文件移动到另一个目录 我的问题是如何从PSFTP应用程序中捕获错误?如果在发送或建立连接时出现错误,我希望生成一个标志,然后我可以用perl捕获该标志,阻止其他任何事情发生,并向我发送电子邮件。我只需要从PSFTP应用程序生成错误标志的指导 提前非常感谢 我的 您应该将应用程序中的STDERR读入Perl。为此目的 有关更多信息,请参阅 use warnin

下面的脚本按预期运行。它调用批处理文件,该文件使用PUTTY或特别是psftp建立连接,并传输少量文件。传输完成后,我继续使用perl脚本将文件移动到另一个目录

我的问题是如何从PSFTP应用程序中捕获错误?如果在发送或建立连接时出现错误,我希望生成一个标志,然后我可以用perl捕获该标志,阻止其他任何事情发生,并向我发送电子邮件。我只需要从PSFTP应用程序生成错误标志的指导

提前非常感谢

我的


您应该将应用程序中的
STDERR
读入Perl。为此目的

有关更多信息,请参阅

use warnings;
use File::Copy;


my $TheInputDir = "//NT6/InfoSys/PatientSurvey/Invision/CFVMC/";
my $TheMoveDir = "//NT6/InfoSys/PatientSurvey/Invision/CFVMC/Completed";

system ('2166_PG_Upload_Batch.bat');


opendir (THEINPUTDIR, $TheInputDir);
@TheFiles = readdir(THEINPUTDIR);
close THEINPUTDIR;


#Get all the files that meet the naming convention
foreach $TheFile(@TheFiles) 
{
    if($TheFile =~ /2166/)
    {
        print "$TheFile\n";
        move ("$TheInputDir$TheFile","$TheMoveDir");

    }
}
my ($stdout, $stderr, $exit) = capture {
     system('2166_PG_Upload_Batch.bat');
   };  
#check for $stderr and do your stuffs i.e sending email etc