I am trying turn on my TV via the web, i am trying to do this via Raspberry PI LibCec module.
when i run echo shell_exec("sudo echo 'on 0' | cec-client -s");
nothing is returned on the php page and my TV is NOT on.
When i run the same command sudo echo 'on 0' | cec-client -s
(or without sudo
) in ssh connection the tv turns on, EVEN when i login as www-data on ssh.
When i run echo shell_exec('whoami');
i do get www-data
as result so whats going on?
The question has been asked before but there isnt any confirmation on the priviliges as answered here: EXEC() in php, cec-client raspberry
YES!
It was a $PATH problem, as i ran
echo $PATH
on php i got a smaller list then i got on my ssh session.So to solve it in my case i used full path towards cec-client which was:
/opt/xbmc-bcm/xbmc-bin/bin/cec-client
as that was the only cec-client i could find...
Hope this helps others!
Would someone please help me by telling me how to make my php session
$path
include the path towards mycec-client
as i dont want to use the full dir all the time.