Page 1 of 1

php run shell script

Posted: Sat Apr 12, 2014 12:10 am
by asd3344
hi


I have script like

Code: Select all

#!/bin/sh
#
echo 1 > /sys/devices/virtual/gpio/gpio4/value

name XX.sh

I want php file has a button when I press this button .. XX.sh run

I tried ( exec , shell_exec )

please help :(

Re: php run shell script

Posted: Sat Apr 12, 2014 3:03 am
by Richard-TX
use full pathnames in your php script
chmod your script to something like 755

Re: php run shell script

Posted: Sat Apr 12, 2014 12:26 pm
by asd3344
Richard-TX wrote:use full pathnames in your php script
chmod your script to something like 755

thanks this what I write in php

Code: Select all


<?php

$output = shell_exec('sudo /var/www/XX.sh');
echo "<pre>".$output."</pre>";
?>

I tried every thing

Re: php run shell script

Posted: Sun Apr 13, 2014 3:45 am
by Richard-TX
The problem is that you are calling sudo and should be calling /usr/bin/sudo.

EVERY command needs the full pathname