Kevin Duke Kevin Duke - 1 year ago 186
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
Answer Source

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, ...

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download