是否可以制作一个将linux命令发送到服务器的API?
我会寻找看起来像这样的东西
// http://localhost/command=netstat
<?php
$command = $_GET['command'];
// Sends server $command
?>
答案 0 :(得分:0)
exec用于执行外部程序。
string exec ( string $command [, array &$output [, int &$return_var ]] )
http://php.net/manual/en/function.exec.php
以下是示例代码;我这样做是为了使用ffmpeg在php中转换视频。
$a = exec('C:\ffmpeg\bin\ffmpeg.exe -i 56c6ed0e49fe0.qt -strict -2 out22.mp4');
希望这会有所帮助。
答案 1 :(得分:0)
shell2http 可以做到这一点。 https://github.com/msoap/shell2http
所以在主机上运行
shell2http -port 8080 /diskspace "df -h"
然后从浏览器远程或使用 curl
run
# assuming host IP is 1.2.3.4
http://1.2.3.4:8080/diskspace
为了在启动时保持持久,我认为你可以运行一个脚本。