2016-03-24 38 views
0

爲什麼this腳本無法在FreeBSD上工作?我在Centos和Debian上運行腳本,一切都很好。在FreeBSD(10.2)我會遇到以下錯誤:爲什麼我的腳本無法在FreeBSD上工作? (awk:語法錯誤)

awk: syntax error at source line 1 
context is 
    match($0, "^listen >>> queue:[[:space:]]+(.*)", <<< 
awk: bailing out at source line 1 
-0.9902 

作爲一個例子,這裏是PHP-形式狀態的一些輸出:

pool:     www 
process manager:  ondemand 
start time:   29/Feb/2016:15:18:54 +0200 
start since:   2083770 
accepted conn:  1467128 
listen queue:   0 
max listen queue:  129 
listen queue len:  128 
idle processes:  1 
active processes:  2 
total processes:  3 
max active processes: 64 
max children reached: 1 
slow requests:  0 

在CentOS和Debian,當我運行:

/path/to/script/php-fpm-check.sh "idle processes" http://127.0.0.1/status 

我得到1,但在FreeBSD上面提到的錯誤。

+0

也許您應該向我們展示有問題的腳本:) –

+0

單詞「this」中的超鏈接 – user3751471

+0

我們需要一個最小示例來重現問題本身的問題。 –

回答

2

match的3參數形式是GNU awk擴展(docs)。你必須找到另一種方法來捕獲匹配(也許使用RSTART和RLENGTH變量作爲match()的副作用),或者在你的freebsd系統上安裝gawk。