fping脚本中描述的脚本有语法错误
问题描述:
我试图运行其手册页中描述的fping脚本。fping脚本中描述的脚本有语法错误
#!/usr/local/bin/perl
require 'open2.pl';
$MAILTO = "root";
$pid = &open2("OUTPUT","INPUT","/usr/local/bin/fping -u");
@check=("slapshot","foo","foobar");
foreach(@check) { print INPUT "$_\n"; }
close(INPUT);
@output=;
if ($#output != -1) {
chop($date=`date`);
open(MAIL,"|mail -s 'unreachable systems' $MAILTO");
print MAIL "\nThe following systems are unreachable as of: $date\n\n";
print MAIL @output;
close MAIL;
}
不过,我从任何地方得到下面的错误我运行它:
syntax error at /path/to/pingtest.pl line 13, near "=;" Execution of /path/to/pingtest.pl aborted due to compilation errors.
有人可以帮助我有什么错线13?我有open2.pl和fping路径是正确的。
答
如果您在线man-page上找到脚本,则<OUTPUT>
已被解释为HTML标记并被删除。它应该阅读
@output = <OUTPUT>;
但这Perl脚本看起来就像是写几十年前
采用
require open2.pl
是long-ago replaced byuse IPC::Open2
它不使用
use strict
或use warnings
,避免词汇变量函数调用使用奥术
&open2
语法,它只有在非常特殊的情况下到
open
的呼叫使用老式的和模糊的两个参数的版本
请链接到你的来源,当您有外部性问题是非常有用的信息 – Borodin