【发布时间】:2014-03-17 17:29:15
【问题描述】:
我正在尝试从 perl 脚本运行批处理文件,但我无法处理批处理文件的返回。下面是我的代码
perl 脚本:
// call a batch file
my $output =system("D:\\WORKSPACE\\CC_Triggers\\batch_file.bat");
// based on output check the status of the batch file
if($output==0){
print "success in trigger**********";
}
else
{
print "FAilure**********";
}
批处理文件:
set "java_output="
setlocal enableDelayedExpansion
//this will call a java program and get return value.
for /f "delims=" %%J in ('java -cp "PMDfileRead.jar;jxl.jar" PMDfileRead') do (
set "java_output=!java_output! %%J"
)
endlocal & set java_output=%java_output%
// check the ouput of java and act accordingly
IF %java_output% == 1 (
echo failed
exit(1);
)else (
echo succeeded
)
基本上我正在尝试验证一个 xls 文件并从批处理文件调用的 java 代码返回标志,然后我需要返回到我无法获得的 perl 脚本。在成功和失败的情况下,我得到的输出是“0”,因为输出是成功的。请求更正我的代码或建议我处理这个问题的最佳方法。
【问题讨论】:
-
所以你回显
failed并且在exit 1之后你的$output中有零?这是完整的批处理文件吗? -
是的,它是完整的文件批处理。我在此处发布之前删除了不必要的代码
-
问题出在批处理脚本中。
perl -e "print map { system(qq{cmd /c exit $_}) >>8 } (0,1)"
标签: perl batch-file