【发布时间】: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。
任何建议将不胜感激。
谢谢。
【问题讨论】: