简体   繁体   English

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

[英]Error on executing libreoffice command using shell_exec()

Code: 码:

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

I have tried this too 我也尝试过

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

Error on the server while executing above: 执行以上操作时服务器上的错误:

Output:sh: /my_files/my_file.doc: cannot execute binary file 输出:sh:/my_files/my_file.doc:无法执行二进制文件

Note: All other commands of linux working fine with shell_exec() just libreoffice command not working. 注意: linux的所有其他命令都可以与shell_exec()一起正常工作,只是libreoffice命令不起作用。 And on linux terminal the libreoffice command working fine just not working using PHP . 在Linux终端上, libreoffice命令可以正常工作,只是不能在PHP工作。

You're using backticks, which tells the subshell to run that command and use its output in its place. 您正在使用反引号,它告诉子Shell运行该命令并在其位置使用其输出。 Use double quotes instead, and it will work far more often. 而是使用双引号,它将更频繁地工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM