Lightshowpi throwing error on browser : Raspberry Pi 3

555 Views Asked by At

I have successfully install Lightshow pi on Raspberry pi 3 and through ssh using below command I can run the music successfully :

sudo python /home/pi/lightshowpi/py/synchronized_lights.py -file=/home/pi/lightshowpi/music/sample/closer.mp3

But I want the music should start from browser for that I have used php to execute the SSH command like below :

exec("sudo python /home/pi/lightshowpi/py/synchronized_lights.py --file=/home/pi/lightshowpi/music/sample/closer.mp3");

I am getting below error :

Need to setup SYNCHRONIZED_LIGHTS_HOME environment variable, see readme.

What I have missed during installation or any changes I have to make in the code to run it from browser?

1

There are 1 best solutions below

0
On BEST ANSWER

I have managed to start the music using below code :

<?php

$x = "sudo python ";
$y = "/home/pi/lightshowpi_new/py/synchronized_lights.py --file=";
$z = $x.$lightshowpihome.$y.'/home/pi/lightshowpi_new/music/sample/closer.mp3';

putenv("SYNCHRONIZED_LIGHTS_HOME=/home/pi/lightshowpi_new");

echo $z;
exec($z);
?>

putenv was the function to set the environment variable in PHP for lightshowpi