6
在linux中,我想從PHP運行一個gnome zenity進度條窗口。如何zenity的工作原理是這樣的:從PHP寫入stdin?
linux-shell$ zenity --display 0:1 --progress --text='Backing up' --percentage=0
10
50
100
所以第一個命令在0%的打開zenity進度條。然後Zenity將標準輸入數字作爲進度條百分比(因此,當您鍵入這些數字時,它將從10%到50%到100%)。
我無法弄清楚如何讓PHP中,雖然輸入這些數字,我曾嘗試:
exec($cmd);
echo 10;
echo 50;
和:
$handle = popen($cmd, 'w');
fwrite($handle, 10);
和:
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w") // stdout is a pipe that the child will write to
);
$h = proc_open($cmd, $descriptorspec, $pipes);
fwrite($pipes[1], 10);
但是他們都沒有更新進度條。以什麼方式可以模仿stdin在linux shell上的效果以獲得更新其進度條的靈活性?
非常感謝!不能相信我忘了換行符! :) – hamstar 2011-03-26 22:04:50