【发布时间】:2015-05-15 05:13:31
【问题描述】:
我遇到了麻烦,并且对 php shell_exec 命令感到非常困惑。 当命令由 PHP 执行时,我没有错误,但执行失败。如果我完全从终端使用相同的命令,它就可以工作。
命令如下:
/usr/bin/wkhtmltopdf --lowquality --dpi 300 --encoding utf-8 "/tmp/knplabs_snappyxa9otq.html" "/tmp/knplabs_snappyv3pD7h.pdf"
当我从终端启动时:
$ /usr/bin/wkhtmltopdf --lowquality --dpi 300 --encoding utf-8 "/tmp/knplabs_snappyWG9XTd.html" "/tmp/knplabs_snappyv3pD7h.pdf"
Loading page (1/2)
Printing pages (2/2)
Done
但是从我的 php 脚本中:
// Construct the previous command
$command = $this->buildCommand($url, $path);
../..
shell_exec($command);
../..
$content = file_get_contents($path);
../..
我已经测试了 shell_exec 的输出,它是空的。
日志:
Warning: file_get_contents(/tmp/knplabs_snappyv3pD7h.pdf): failed to open stream: No such file or directory in /*****/lib/snappy/SnappyMedia.class.php on line 64
在/tmp目录下没有pb权限:
$ ls -la /tmp
total 448
drwxrwxrwt 16 root root 4096 mars 12 21:51 .
../..
我已经尝试使用 PHP exec() 函数来获取错误信息,我只是在 return_var 中得到一个“1”错误代码,而输出中没有任何内容。
有关信息,此问题出现在我的测试服务器、我的台式计算机上,但没有出现在我的笔记本上。所有 3 都具有相同的 PHP、Apache、Mysql 版本。 我什么都不懂……
感谢您的帮助,我疯了。 大卫。
【问题讨论】:
标签: php wkhtmltopdf shell-exec