【问题标题】:Use shell script to execute java saxon transform to create file使用shell脚本执行java saxon transform创建文件
【发布时间】:2017-10-18 00:05:36
【问题描述】:

我一直在尝试使用 PHP 执行 shell 脚本 (.sh) 并执行 Java saxon.transform 来创建文件。当我运行 PHP 文件时,它没有显示任何错误,但文件没有被创建。

script.sh 是可执行的(chmod +x),jar 路径是预定义的。

script.sh

echo "Running step 01."
java net.sf.saxon.Transform -o:review.html -s:merged.html -xsl:xsls/01-simplify.xsl --suppressXsltNamespaceCheck:on;

if [ -f "review.html" ]
then
    echo "Review.html file successfully generated."
    echo "Done"
else
    echo "Something went wrong."
    echo "Check the <code>merged.html</code> file."
fi

php

echo shell_exec('./script.sh');

结果

Something went wrong.
Check the merged.html file.

从命令行执行时,相同的 java 命令可以正常工作。它只是在网络上不起作用。

我在 Ubuntu 16.04 上,使用 PHP7。

任何建议将不胜感激。

谢谢。

【问题讨论】:

    标签: java php shell xslt saxon


    【解决方案1】:

    如果您检查您的 error.log 文件,它应该会为您提供有关问题所在的更多详细信息。使用命令:

    tail /var/log/apache2/error.log -n 100

    或类似

    我尝试在 php 环境中运行类似的 shell 脚本。我收到以下错误:

    test.xsl 的第 7 行出错: 无法创建输出文件 file:/var/www/html/samples/review.html: Permission denied 在内置模板规则中 创建输出文件失败:/var/www/html/samples/review.html

    这可能是您在创建输出文件时遇到的权限问题。

    【讨论】:

      猜你喜欢
      • 2020-04-16
      • 2019-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多