php - 使用 php 返回码 77 执行系统命令
问题描述
我正在尝试使用 libreoffice 将 word 文档转换为 pdf。该命令在终端中运行良好,但在我用 php 编写的应用程序的控制器中使用shell_exec()
,否则exec()
它不起作用。exec()
的 return_var 是 77,我认为这意味着:
错误的文件描述符
任何建议都会受到高度赞赏。
解决方案
我添加了这个命令选项来修复它:
-env:UserInstallation=file:///tmp/test
我的代码是:
$command = "{$bin} -env:UserInstallation=file:///tmp/test --headless --convert-to pdf:writer_pdf_Export --outdir '{$pdfTmpDir}' '{$path}' 2>&1";
exec($command, $output, $code);
推荐阅读
- python-3.x - Youtube_DL Python 实现类型错误的 Youtube 提取器:add_cookie_header() 缺少 1 个必需的位置参数:“请求”
- json - (Swift)如何解析有时包含某个字段的 JSON 响应?
- c - 从开关引脚 Tiva c Launchpad 读取数据
- python - Pylint 不理解 if/else 语句?
- docker - 如何获取在 docker 映像中定义的入口点以将其包装在 helm 安装中
- hibernate-search - Hibernate Search 6.0.2.Final 与 opendistro
- macos - 如何在 macOS 上获取屏幕时间数据?
- python - 仅当消息从 certin 客户端发送时如何批准消息(具有线程的 Python 多客户端套接字服务器)
- python - 如何使用 Python 检查多个值是否包含 CSV 数据集?
- python - 如何在功能仍在运行时单击按钮两次?