2010-05-05 191 views
2

shell_exec()了shell_exec()和exec()不顯示輸出

我做一個使用shell_exec()功能這樣的PHP網站:

$file = "upload/" . $_FILES["file"]["name"]; 

$output = shell_exec("leaf $file"); 
echo "<pre>$output</pre>"; 

其中葉是一個程序,位於我腳本的同一目錄中,但是當我嘗試在服務器上運行此腳本時,我什麼都沒有。


exec()

如果我嘗試使用exec()這樣的:

exec("sh " . getcwd() . "leaf -h", &$output); 
echo "<pre>"; 
print_r(&$output); 
echo "</pre>"; 

我得到這個:

Array 
(
)

如果我做同樣的事情,但使用echo而不是print_r,我只得到這個:Array

我能做什麼?

回答

2

您是否嘗試過使用「葉」參考的完整路徑?

$output = shell_exec("/var/local/leaf $file"); 
+0

是啊,我已經做到了這一點:'$輸出=了shell_exec,',但我什麼也沒得到過( 「sh」 的GETCWD() 「/葉$文件」。)。 – 2010-05-05 17:41:53

+0

你可以嘗試使用一個靜態路徑,看看是否改變了什麼? getcwd()很可能會從Apache獲得CWD,這可能與您的想法不同。你也可以參考error_log尋找線索。 – gurun8 2010-05-05 17:53:25

+0

我已經把靜態路徑,我什麼都沒有。 – 2010-05-05 18:05:10