I have a linux server running ubuntu 10.10 maverick with apache and php installed, in the /var/www directory I have a download directory. I have used OSFile manager and modified to include a function to split files here is the code:
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();
}
The command does not execute. The file and directory is correct but it returns exit code 1, and Array() as the output values, I have created a group that includes a few users, I have made this group the owner of downloads/ and given it read write and execute permissions, this group includes www-data.
Any Help will be apreciated
IF you don't get any error messages from exec and the error.log stays empty, then use this wrapper for executation:
exec("sh -c \" $cmd 2>&1 \"");
The 2>&1
redirects the stderr
channel to stdout
, so that it shows up in the result array.
In the shell, what does " 2>&1 " mean?
Another option would be proc_open
where you can read each channel separately, but is more work to set up.
try this file split class
or this using exec Split big files using PHP using exec