I want to create a webpage control page to my remote server.
I want to be able to run my own local scripts by pressing buttons on the webpage.
I have followed some advice from (stackoverflow) and created this:
<?php if (isset($_POST['button'])) { exec('//xxx.yy.zz.v/Users/me/webtest.sh'); } ?>
<form action="" method="post">
<button type="submit" name="button">MY TEXT</button>
</form>
webtest.sh:
#!/bin/sh
set -x
echo "WOW ME" > /cygdrive/d/jobs/web.test
It does not appear that webtest.sh runs when I press the button.
First check this line exec('//xxx.yy.zz.v/Users/me/webtest.sh');
to execute a sh file from php you need to use ./path/file.sh or sh path/file.sh
can be exec('./path/file.sh')
, then set appropriate file permission to webtest.sh and web.test so that webserver can access those file. You can check the error logs in
tail -f /var/log/apache or http/errorlogs