如何从PHP中使用shell_exec执行program_linux_i386

huangapple go评论58阅读模式
英文:

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&#39;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>



huangapple
  • 本文由 发表于 2023年7月20日 19:58:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/76729629.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定