douyi3833 2014-12-16 13:24
浏览 45

从PHP脚本exec()执行时无法从gradle获取输出

I am trying to build an Android application by executing Gradle from a PHP script using exec(), but there is no response, so I am unable to see why the build fails.

When executing the applications gradle wrapper from the terminal (SSH), the whole process works fine, using the following commands:

x:/path/to/project/$ ./gradlew assembleRelease
x:/path/to/project/$ ./gradlew assembleRelease --debug --stacktrace
x:/path/to/project/$ ./gradlew assembleRelease --debug --stacktrace > output.txt

The output works fine and I am able to troubleshoot any possible problems. When executing gradle from a PHP-script, there is no output.

// array for the output to be dumped into
$output_array = array();

// $result is empty (tried with stacetrace, debug and an output file)
$result = exec("cd /path/to/project && ./gradlew assembleRelease", $output_array);

// nothing displayed
var_dump($output_array);

There is no way of me telling where the problem is. I have checked that the required environment variables ($GRADLE_HOME and $ANDROID_HOME) are set using getenv() and they point to the correct path.

Any help would be great!

  • 写回答

1条回答 默认 最新

  • doujie3888 2014-12-16 13:53
    关注

    I'm no linux specialist, but it seems you launch it (ssh) from "~/path/to/project" (~ meaning your home path).

    In php, you're trying to launch it from "/path/to/project" (absolute path from root folder).

    try to replace your second command by "ls" so you'll see where you are... and compare with where you should be!

    评论

报告相同问题?

悬赏问题

  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序