doudaotui4297 2012-01-07 18:06
浏览 30
已采纳

将Bash与PHP集成

Is it possible to integrate the two?

I found this example on the net, but it outputs a blank page. bash on its own is working and outputs Hello World!

bash with 0777 chmod echo.txt

  #!/bin/bash
   echo "Hello World!"

PHP

<?php
$result=shell_exec("echo.txt");
echo($result);
?>
  • 写回答

3条回答 默认 最新

  • duanlan4801 2012-01-07 18:17
    关注

    Specify the path to echo.txt, relative to the PHP script or absolute path, and make sure the script is executable.

    $ chmod +x echo.txt
    
    <?php
    $result=shell_exec("./echo.txt");
    echo($result);
    ?>
    

    Without specifying the relative path, and running the PHP from the command line, the output was

    sh: echo.txt: command not found
    

    It will work properly with the path specified.

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

报告相同问题?

悬赏问题

  • ¥15 Qt下使用tcp获取数据的详细操作
  • ¥15 idea右下角设置编码是灰色的
  • ¥15 全志H618ROM新增分区
  • ¥20 jupyter保存图像功能的实现
  • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示
  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键