Java工作来自putty而不是来自php

I have very strange problem. I have jar file on my dedicated server. When i call this jar file from putty is work very well, but when i call this script from php this work only sometimes.

from putty i call and it's work very well

java -jar filmweb.jar http://www.filmweb.pl/film/101+dalmaty%C5%84czyk%C3%B3w-1996-633

from php i call my script like this

if($_SERVER['QUERY_STRING'] == ""){
    echo "podaj parametr w get /?[adres filmweb]";
    exit;
}

/*
echo $_SERVER['QUERY_STRING'];
echo clean($_SERVER['QUERY_STRING']);
exit;
*/
$shell = 'java -jar filmweb.jar '.clean($_SERVER['QUERY_STRING']).'';
$url = sha1(clean($_SERVER['QUERY_STRING'])).".txt";
$file = file_get_contents($url);
//echo $url."   ";
if( @ $file ){
    //echo 'juz mam';
    if($file != ""){
        echo file_get_contents($url);
        exit;
    }
}
//echo 'odpalam skrypt';
$output = exec($shell);

//echo $output;
if($output != "null"){
    $s = file_get_contents($output);
    if($s == ""){
        file_put_contents("issue.txt", clean($_SERVER['QUERY_STRING'])."
", FILE_APPEND);
        echo "###### BUG #####"."<br>";         
        echo "> url #  ".$_SERVER['QUERY_STRING']."<br>";
        echo "url > #  ".clean($_SERVER['QUERY_STRING'])."<br>";
        echo "> jar #  ".$shell."<br>";
        echo "jar > #  ".$output."<br>";
        echo "file= #  ".$s."<br>";
    }else{
        echo $s;
    }
}else{
    echo "null,";   
    echo $shell;
}

function clean($s){
    return utf8_encode($s);
}

My jar file generate txt file with data from one page. When i call script from php sometimes this file is empty and php script show me command. Then i copy this command, paste in putty and everything work well! It is very strange problem. Any idea?

Thank you.

Ok, i solve my problem :)

I looking after an answer from week. I don't have free space on my domain. Less than 18.37 / 20 GB. When php run jar file then script create empty file. When i call putty every things work well. I think it is depended from root privilege.

Thanks edlerd, when you sad about memory i decide to check free space. Thanks again.

Maybe its a memory problem. Try this on top of your php file

ini_set('memory_limit','256M');

Though this might not be allowed, and you have to change the memory setting in the base config for php.

Also check the log files of your webserver or php-fpm und /var/log/