doupinyan0186 2014-11-26 21:54
浏览 38
已采纳

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.

  • 写回答

2条回答 默认 最新

  • douxuan4556 2014-11-26 22:52
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值