Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was wondering what is needed to trigger a shell script with a HTTP post request. Being in my home wifi I want to call and have a script triggered on my host. I guess I have to run a webserver on the host. But what else is needed in addition? Is this the right place to ask that kind of question? Thanks!

share|improve this question
up vote 2 down vote accepted

This is a very broad question. I would install Apache and PHP on the server and then you can use a very simple PHP script to run the script. Nothing else should be required.

In your web root directory, place a script and a php file:


echo "Hello World"


    $output = shell_exec('./');
    echo $output;

Run this using localhost/run_script.php.

You can then run any script you want (you should not place it in your web root!)

If you only want to run this on an HTTP Post request, then wrap the script in

if ($_SERVER['REQUEST_METHOD'] === 'POST') { ... }

And you can check for Post parameters with

if ($_POST['parameter']) { ... }

Note: There are many caveats with this, but they are better addressed as separate questions. This should get you going, anyway.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .