【发布时间】:2020-03-05 12:03:03
【问题描述】:
我正在开发一个 3D 打印网页。为了计算材料和时间,我试图让网络在文件上运行 cura-engine 软件(控制台程序)。
我在 Google Cloud Platform 中创建了一个虚拟机,在 debian 10 下运行 LAMP 堆栈。我使用 apt 安装了 cura'engine 包,我可以从终端(通过 ssh)运行它:
eduardoj_vieirav@instance-1-vm:/var/www/html$ CuraEngine
Cura_SteamEngine version 3.3.0
Copyright (C) 2018 Ultimaker
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
...
但是当尝试使用 exec 或 shell_exec 使用 php 执行此命令时,我没有输出。
<?php
echo exec('CuraEngine');
?>
我也尝试过对文件执行操作,我可以再次使用以下命令从 ssh 执行此操作:
eduardoj_vieirav@instance-1-vm:/var/www/html$ CuraEngine slice -v -j resources/definitions/creality_ender3.def.json -o gcode/output.gcode -l STL/cube.stl
但它又不能从 php 运行
<?php
echo exec('CuraEngine slice -v -j resources/definitions/creality_ender3.def.json -o gcode/output.gcode -l STL/cube.stl');
?>
我觉得奇怪的是我无法执行 CuraEngine,因为其他命令(例如 uname -a0)会返回输出。
【问题讨论】:
-
我正在尝试做和你一样的事情。我尝试过的事情:从 sh 文件运行 CuraEngine;并将终端输出重定向到带有
CuraEngine -options 2> cura_output的文件。到目前为止没有运气。使用 shell_exec 调用时,CuraEngine 不运行。你设法解决了吗?谢谢