0

I am working on Vagrant and trying to build html page to be displayed (localhost only), and I want to have a button that will run shell script (also on Vagrant)

I've tried this solution - Run a shell script with an html button but the button is downloading php file.

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');
?>

script:

#!/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

all the files are in the same directory

Halina V
  • 49
  • 1
  • 6

0 Answers0