【发布时间】:2021-12-14 17:28:03
【问题描述】:
下面是我要执行的代码。我已经在代码中提到了第 266 行。我已添加该代码以删除日志文件中的空白行。我不确定我们是否可以在 Perl 脚本中运行 perl 命令。有没有其他方法可以运行它,以便我可以删除日志文件中的空白行?
以下是我在运行 Perl 脚本时遇到的错误:
syntax error at ./reportJBossErrors.pl line 266, near "n -e "
Execution of ./reportJBossErrors.pl aborted due to compilation errors.
这是部分代码,显示第 266 行:
sub main {
readConfiguration($config_file);
$short_hostname = `hostname | cut -f 1 -d.`;
chomp $short_hostname;
getFileandInstance($short_hostname);
$yesterday = getYesterday();
validateEnvironment();
$log_file = getLogFile($FMASK,$yesterday);
perl -i -n -e "print if /\S/" $log_file; # 266 line. This is where I'm getting the compilation error
processFile($log_file);
$html_out = writeEmail();
sendEmail($CONFIG{"FROMADDR"},$CONFIG{"TOADDR"},"Normal",
"JBOSS",$short_hostname,$log_file,$CONFIG{ENVTYPE},$html_out);
}
【问题讨论】:
标签: perl