簡體   English   中英

PHP exec 不返回 awk 輸出

[英]PHP exec not returning awk output

我正在嘗試通過 PHP 獲取以下 awk 命令的輸出,但沒有輸出

$time_ref = date("Y-m-d\TH:i:s",strtotime(date('c', (time() - 80)))); //2020-03-29T21:00:30

$s_string = 'awk \'$0 > "'.$time_ref.'" && $0 ~ "AAA4311A01A404C4E21ABE55"\' /var/log/syslog | tail -1';  

echo shell_exec($s_string);

直接從控制台運行 awk 它可以工作:

pi@raspberrypi:/var/log $ awk '$0 > "2020-03-30T10:06:28" && $0 ~ "AAA4311A01A404C4E21ABE55"' syslog

2020-03-30T10:07:40.300908+02:00 RadioBridge ESP-RSL: RESULT = {"RfRaw":{"Data":"AAA4311A01A404C4E21ABE55"}}

關於為什么它不能從 PHP 工作的任何建議?

There are many solution. 
1) if  you run the PHP file in web, you should set the permission to the awk file. 
2) we should set the path of the "awk"
$PATH = "real path";
putenv("PATH=$PATH");
$_string = "./awk ...."

Thanks.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM