使用shell_exec()执行libreoffice命令时出错

时间:2019-01-18 16:06:24

标签: php linux shell libreoffice

代码:

shell_exec('libreoffice --convert-to pdf `'.$my_file.'` --headless');

我也尝试过

shell_exec('libreoffice --convert-to pdf `'.$my_file'` --headless > /dev/null');

以上执行时服务器上的错误:

  

输出:sh:/my_files/my_file.doc:无法执行二进制文件

注意:linux的所有其他命令都可以与shell_exec()一起正常工作,只是libreoffice命令不起作用。在Linux终端上,libreoffice命令可以正常工作,只是不能使用PHP

1 个答案:

答案 0 :(得分:1)

您正在使用反引号,它告诉子Shell运行该命令并在其位置使用其输出。而是使用双引号,它将更频繁地工作。

相关问题