****UPDATE****
# The issue was within the wanpipemon script and the way that it interacts
# with ioctl basically unless you want to edit the source for wanpipemon
# and recompile it, it will not work. I have tried -S with root among
# others and unless I am within console it throws a not authorized error
# in the ioctl function.
好吧,我有一個運行命令,並輸出FXO線電壓一個簡單的shell腳本,通常你會在某一時刻得到一個線這個結合他們到一個可讀的輸出。 (不相干的這篇文章,但我想有人會問這個腳本做什麼)PHP了shell_exec() - 不打印動態輸出,只打印靜態回聲文本
這是shell腳本:
#!/bin/bash
LINE1=$(wanpipemon -i w1g1 -c astats -m 1 | grep -m1 VOLT | cut -d ":" -f 2-2)
LINE2=$(wanpipemon -i w1g1 -c astats -m 2 | grep -m1 VOLT | cut -d ":" -f 2-2)
LINE3=$(wanpipemon -i w1g1 -c astats -m 3 | grep -m1 VOLT | cut -d ":" -f 2-2)
LINE4=$(wanpipemon -i w1g1 -c astats -m 4 | grep -m1 VOLT | cut -d ":" -f 2-2)
LINE5=$(wanpipemon -i w1g1 -c astats -m 5 | grep -m1 VOLT | cut -d ":" -f 2-2)
LINE6=$(wanpipemon -i w1g1 -c astats -m 6 | grep -m1 VOLT | cut -d ":" -f 2-2)
echo "Line 1 Voltage: $LINE1"
echo "Line 2 Voltage: $LINE2"
echo "Line 3 Voltage: $LINE3"
echo "Line 4 Voltage: $LINE4"
echo "Line 5 Voltage: $LINE5"
echo "Line 6 Voltage: $LINE6"
通過終端運行計算機上的腳本,它的偉大工程完美真的。在我的PHP腳本,我只是做(PHP腳本是在同一臺服務器的SH文件上):
<?php
$output = shell_exec('/usr/sbin/linesta.sh');
echo "<pre>$output</pre>";
?>
我在運行該腳本的瀏覽器收到的輸出是:
Line 1 Voltage:
Line 2 Voltage:
Line 3 Voltage:
Line 4 Voltage:
Line 5 Voltage:
Line 6 Voltage:
現在我已經確定這些權限是正確的,並且應該已經知道,因爲它運行了50%的方式,並且就像我所說的,我知道該腳本在機器上運行。
這真的很奇怪,因爲它輸出的是靜態文本而不是動態文本。命令'wanpipemon -i w1g1 -c astats -m *'是我的PBX上模擬卡的驅動程序應用程序的一部分,不需要root來運行它(任何用戶都可以運行該命令),所以它讓我困惑於什麼正在進行。
任何幫助和/或調試建議將非常感謝,迄今爲止,我只嘗試了雙重檢查shell腳本的權限,在控制檯上運行服務器上的腳本(即linesta.sh),但我不確定什麼別的來測試。我嘗試了其他PHP命令,例如exec()和system(),其結果完全相同。
我最終什麼事做了分配cron作業運行腳本,cron作業將要運行腳本,並採取輸出,並將其寫入到文件中, PHP將通過readfile獲取信息。不是最好的解決方案,但對我來說,我想是夠了。只是想我會補充我在這裏所做的,以便其他任何想要監視模擬線路的人都可以輕鬆地做到這一點。 – BrandonS