通过PHP执行.sh脚本

dev*_*evs 4 php linux sh

我有一些游戏服务器,我需要运行shell脚本以获得频率.我试图弄清楚如何通过同一台服务器上的网页运行这些脚本.这是一个Ubuntu Dedicated服务器.

网站文件通过/var/www/...我需要手动运行的.sh文件找到/home/amservers/.../start.sh.

我看了其他的答案,我仍然无法弄清楚.如何找到并存储它然后运行exec()?

Dan*_*ing 9

您可以在PHP中使用shell_exec()函数:

http://php.net/manual/en/function.shell-exec.php

shell_exec('sh script.sh');
Run Code Online (Sandbox Code Playgroud)

如果你想使用变量(bash中的$ 1,$ 2等),你可以输入:

shell_exec('sh script.sh variable1 variable2');
Run Code Online (Sandbox Code Playgroud)