我想從PHP執行Linux shell命令但網頁上沒有輸出。如果我試圖執行從PHP COOL的PHP頁面,它的工作正常。在網頁PHP沒有輸出,同時執行shell命令
PHP代碼:
<?php
$result = shell_exec('asterisk -rx "core show channels concise"');
$ccount =shell_exec('asterisk -rx "core show channels count"');
echo $result;
echo $ccount;
?>
上面的代碼是不給網頁上的任何輸出。但在Linux控制檯上它的woking。例如所有的問題
[ABC @主機sysadminman]#PHP myfile.php
也許apache用戶沒有權限。錯誤日誌顯示什麼? – chris85
您需要在shell_exec調用中找到可執行文件路徑。例如/ usr/bin/asterisk -rw「core show channels concise」 – unixmiah