Kevin Duke Kevin Duke - 1 month ago 10x
HTML Question

Run a shell script with an html button

I want to launch a bash script when a button is pressed on a website.
This is my first attempt:

<button type="button" onclick="/path/to/">Click Me!</button>

But no luck. Any suggestions?

nsg nsg

As stated by Luke you need to use a server side language, like php. This is a really simple php example:

if ($_GET['run']) {
  # This code will run if ?run=true is set.

<!-- This link will add ?run=true to your URL, myfilename.php?run=true -->
<a href="?run=true">Click Me!</a>

Save this as myfilename.php and place it on a machine with a web server with php installed. The same thing can be accomplished with asp, java, ruby, python, ...