我正在研究Vagrant并尝试构建要显示的html页面(仅限localhost),我想要一个将运行shell脚本的按钮(也在Vagrant上)
我已经尝试过这个解决方案 - Run a shell script with an html button但按钮正在下载php文件。
HTML:
<!DOCTYPE html>
<html>
<body>
<h1>Demonstration for calling Shell Script from a web page</h1>
<form action="/home/vagrant/whirlygig/testexec.php">
<input type="submit" value="Open Script">
</form>
</body>
</html>
PHP:
<?php
exec("/home/vagrant/whirlygig/cleanup");
header('Location: http://localhost:8080/index.html?success=true');
?>
脚本:
#!/usr/bin/env bash
sudo rm inventory.txt
sed -i '8d' roles/loadbalancer/vars/main.yml
sed -i '8d' roles/loadbalancer/vars/main.yml
sed -i '2d' hosts
所有文件都在同一目录中