即使成功完成,PHP shell_exec'wkhtmltopdf'也会返回null

时间:2013-06-24 16:19:41

标签: php linux apache wkhtmltopdf shell-exec

docs for PHP shell_exec中,它表示如果发生错误,shell_exec函数将返回null。不幸的是,当我运行以下代码时,代码全部正确完成,但shell_exec命令仍返回null

// convert to PDF
$output = shell_exec('wkhtmltopdf --page-size Letter report.html report.pdf');
if (is_null($output)){
    echo("error creating pdf, please contact IT administrator.");
}

我可以告诉它正确完成,因为1)PDF文件是正确创建的,2)因为我检查了apache error_log(由于某种原因包含了wkhtmltopdf命令的输出),输出说明了该过程的每一步正确完成。

这是一个问题,因为我无法从PHP程序判断命令是否正确完成。因此,即使没有发生错误,上述脚本也会随着错误消息而死亡。

这是输出是apache错误日志(与命令行直接执行时命令行上的输出相同): enter image description here

有谁知道为什么会这样?或者我如何以不同的方式正确报告错误?

  

Linux Ubuntu 12.10

     

PHP 5.3.6-13ubuntu3.9

0 个答案:

没有答案
相关问题