0

There is a clean way to execute a bash script by clicking on a button inside a webpage (and possibly pipe back the result)?

I'm making a slideshow using reveal.js and I will need to execute a few commands on the shell but I'd like to avoid slowing down the presentation by going back and forth to the console.

I suppose it's not possible because it would open huge security holes but I'm no expert, so here I am asking it ^^.

All I can think of is a very ugly and hackish method using ajax and a looping script on my machine that checks on my server what to do and pass it to the console.

1 Answer 1

0

This can be done, but it is a huge security hole. One of the ways you could go about it is via PHP, using shell_exec.

You can create a php page say like this:

<?php
$Display_Results = shell_exec('ls -alh');

echo "<pre>$Display_Results</pre>";
?>

You can then call that page however you would like. You can even pass variables via GET.

1
  • Right, I can use Apache instead of the looping script, I will think about what suits my needs better. I will also try to secure it a bit, It just has to stay on for a limited ammount of time (the presentation). Probably a list of hardcoded one time passwords could do the job, even if someone is sniffing the traffic they wont be able to do much.
    – Fiochkij
    Commented Nov 18, 2016 at 16:26

You must log in to answer this question.

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