英文:
How to shell_exec program_linux_i386 from PHP
问题
我下载了(mdldec_linux_amd64)和(mdldec_linux_i386),并将它们放在 cPanel / 文件管理器 / HTML 文件夹的某个位置。
如何从 Call.PHP 中调用这个程序?
我尝试了以下的方法:
shell_exec("mdldec_linux_amd64 参数1 参数2");
有人可以帮助我吗?
英文:
I downloaded (mdldec_linux_amd64) and (mdldec_linux_i386)
and placed them somewhere in cPanel / Files Manager / HTML folder
How to call this program from Call.PHP ?
I try something like below
shell_exec ("mdldec_linux_amd64 parameter1 parameter2");
can someone help me on this?
答案1
得分: 2
执行来自PHP的命令不建议,这可能会带来安全问题。如果没有其他选择,以下是两个示例:
你应该尝试使用要执行的文件的完整路径:
shell_execute("/usr/local/mdldec_linux_amd64 parameter1 parameter2");
假设文件位于/usr/local文件夹中
另外,你可以使用exec,并获取执行命令的最后一行返回值,还可以获取完整的输出:
$lastLine = exec("/usr/local/command",$output);```
这样你可能能够更好地进行调试并获得更多信息。
<details>
<summary>英文:</summary>
Executing commands from php is not recommended, this might bring security issues. If you don't have an option here are 2 examples:
You should try to use the full path for the file you want to execute:
shell_execute("/usr/local/mdldec_linux_amd64 parameter1 parameter2");
Assuming that the file is the /usr/local folder
Also you can use exec and get the last returned line from the executed command. and also the full output
$output = array();
$lastLine = exec("/usr/local/command",$output);
And you might be able to debug better and have more information
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论