dongzhan9100 2015-12-24 11:18
浏览 98
已采纳

HTML不显示字符

I'm running lighttpd 1.4.35 on Debian 8.2. I have a very simple html file with php code (php5) which calls a bash script and prints the output:

<html>
<body>
<?php
    $res = shell_exec("/var/www/html/run.sh");
    echo $res . " is the result";
?>
</body>
</html>

If that html file is called on firefox, the output is

 is the result

If I directly run php with that file (php index.php), the output is

<html>
<body>
13.00
 is the result</body>
</html>

So, where does the result get lost?


edit: The webpage source code from firefox is

<html>
<body>

 is the result</body>
</html>

edit: solved. bash script uses '~' which expands to wrong directory when the script is run from webserver.

  • 写回答

2条回答 默认 最新

  • dstbp22002 2015-12-24 11:37
    关注

    The exec functions "only" return the contents of stdout, which is why you might miss an error message.
    But you can redirect stderr to stdout, e.g. via

    $res = shell_exec("/var/www/html/run.sh 2>&1");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制