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.