我有一臺運行ubuntu 10.10的linux服務器,在安裝了apache和php的maverick中,在/ var/www目錄中有一個下載目錄。我已經使用OSFile經理和修改,以包括一個函數來這裏分割文件是代碼:在Linux服務器上執行PHP exec split命令
function spl($fname){
global $folder;
if (!$fname == ""){
maintop("Split");
$dirfile = $folder.$fname;
\\escape directory path
$dirfile = str_replace(" ","\ ",$dirfile);
$dirfile = str_replace("(","\(",$dirfile);
$dirfile = str_replace(")","\)",$dirfile);
$command = "split -d -b1024m ".$dirfile." ".$fname."_";
echo "Command: ".$command;
echo"<br />";
$returnval =0;
unset($output2);
$output = exec($command,$output2,$returnval);
//echo results
echo($output);
echo"<br />";
print_r($output2);
echo"<br />";
echo($returnval);
echo"<br />";
mainbottom();
}
else
home();
}
該命令不執行。文件和目錄是正確的,但它返回退出代碼1,並且Array()作爲輸出值,我創建了一個包含幾個用戶的組,我已經使該組成爲下載的所有者/並且讓它讀取寫入並執行權限,這個組包括www-data。
任何幫助將apreciated
提示1:使用'addcslashes'或'escapeshellarg'。提示2:如果不捕獲任何錯誤消息,請查看'error.log'。 – mario
error.log位於何處?我試過escapeshellarg,但它沒有對文件路徑做任何事情。 –
這是一個網絡服務器文件。經常在文根上面。如果需要,Escapeshellarg可以在單引號和反斜線之間添加單引號。 – mario