dchurch24
December 2nd, 2012, 02:34 PM
Hi all,
I have an ongoing development of a home automation system that I've been building/amending/adding to for years.
Now I want to be able to control all the devices in my house via an internal web page.
I've set up a RPi box and installed lamp - I now have a prototype web page (www.cidb.co.uk/homecontrol if anyone is interested), when I click any of the buttons it executes a PHP page via ajax and returns the results.
I have a set of scripts that are as such:
switch_1_on.sh
switch_1_off.sh
etc...
if I'm at the command prompt and I type ./switch_1_on.sh it executes the following command successfully and switches a relay on, that in turn switches a remote 433mhz device.
echo -e '\xff\x05\x01' > /dev/ttyUSB0
At the terminal, this works fine and executes as expected.
The php page that calls this script is this:
<?php
$inp = shell_exec('./switch_1_on.sh'); // > /dev/null 2> /dev/null &');
echo $inp;
?>
The code is executed (I know this as I added 'echo "hello";' into it and that is returned correctly....but the shell scripts never switches the relay.
I guessed that it was a permissions problem, so temporarily changed the file to 777, that didn't work, so I made the owner www-user, but that didn't work either.
I'm now at a complete loss.
Anyone got any ideas why the script can run normally at the terminal, and run all the parts of the script through php apart from the serial parts?
I have an ongoing development of a home automation system that I've been building/amending/adding to for years.
Now I want to be able to control all the devices in my house via an internal web page.
I've set up a RPi box and installed lamp - I now have a prototype web page (www.cidb.co.uk/homecontrol if anyone is interested), when I click any of the buttons it executes a PHP page via ajax and returns the results.
I have a set of scripts that are as such:
switch_1_on.sh
switch_1_off.sh
etc...
if I'm at the command prompt and I type ./switch_1_on.sh it executes the following command successfully and switches a relay on, that in turn switches a remote 433mhz device.
echo -e '\xff\x05\x01' > /dev/ttyUSB0
At the terminal, this works fine and executes as expected.
The php page that calls this script is this:
<?php
$inp = shell_exec('./switch_1_on.sh'); // > /dev/null 2> /dev/null &');
echo $inp;
?>
The code is executed (I know this as I added 'echo "hello";' into it and that is returned correctly....but the shell scripts never switches the relay.
I guessed that it was a permissions problem, so temporarily changed the file to 777, that didn't work, so I made the owner www-user, but that didn't work either.
I'm now at a complete loss.
Anyone got any ideas why the script can run normally at the terminal, and run all the parts of the script through php apart from the serial parts?