I am trying to run a .sh file from within a php file in Apache2 html folder. I have installed Apache2 and PHP on the Pi. I have given permission to www-data to execute the file. The .sh file excutes from the terminal.
<?php
if (isset($_GET['led1'])) {
if($_GET['led1'] == 1) {
echo "**RESPONSE**";
echo " ";
exec('sh /home/pi/AlarmCode/StartAlarm.sh');
echo "**POSITIVE**";
} else {
exec("gpio write 0 0");
}
}
?>
I can call the web server and get a response from my pc. Any help would be greatly appreciated.
I have also tried echo shell_exe
Thanks in advance