1
我需要替換半徑autentification腳本(用於PPPoE連接)。這是一個24/7全天候運行的服務,因此爲了測試新腳本,我在原始腳本的開始處注入了一小段代碼,以分叉一個稱爲新腳本的新進程(如果新腳本沒有破壞的危險腳本失敗)。這是注入代碼:反撥操作員返回狀態碼5(或1280)
$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是什麼意思? 如何在反引號中調試命令以找出發生了什麼問題?