我需要替换一个半径认证脚本(用于 PPPoE 连接)。这是一个 24/7 运行的频繁使用的服务,所以为了测试新脚本,我在原始脚本的开头注入了一个小代码来派生一个调用新脚本的新进程(如果新脚本没有破坏某些东西的危险脚本失败)。这是注入的代码:
$pid = fork();
if($pid == 0)
{
my $now_string = POSIX::strftime "%a %b %e %H:%M:%S %Y", localtime;
open(FILE,">>/new_log_file.log");
`/new_script_path/new_script.pl @ARGV`;
if ($? == 0)
{
print FILE "[".$now_string."] Chiled executed succesfuly\n";
} elsif($? == -1)
{
print FILE "[".$now_string."] FAILED to execute\n";
} elsif($? & 127)
{
printf FILE "[".$now_string."] child died with signal %d, %s coredump\n", ($? & 127), ($? & 128) ? 'with' : 'without';
} else
{
printf FILE "[".$now_string."] child exited with value %d\n", $? >> 8;
}
close(FILE);
exit;
}
不幸的是,这无法执行新脚本,并且在日志文件中我收到了以下消息:
"[Mon Feb 27 09:25:10 2012] child exited with value 5"
在不移动位的情况下,$ 的值?是 1280;
如果我手动调用它,新脚本将按预期工作。
状态码 5 是什么意思?如何调试反引号中的命令以找出问题所在?