Log shows your macro is being executed so that part is OK. The reason why it is not working (but working from command line) is probably to do with permissions. When a macro is run by the system then it is being run by user www-data. If the operations that the script is trying to perform are not allowed for this user then it won't work, whereas from the command line it is being run as user (pi) and then does work.Arrebar wrote:I am preparing a home security camera system for someone. For this purpose I use a raspberry pi 3 with the original camera and display. To prevent the display to be on 24/7 I have installed a screensaver on the raspberry.
Upon motion detection, I want run a script that stops the screensaver. The script works when I use it from the commandline, but it does not work from the RPI cam web interface. The log shows the script is executed, however, nothing happens:
[2017/01/21 20:22:17] Start capture requested from Pipe
[2017/01/21 20:22:17] Send sy screen.sh
{2017/01/21 20:22:17} Executing macro /var/www/html/macros/screen.sh &
[2017/01/21 20:22:19] Send im
In the macros folder, ls -l will give -rwxrwxrwx 1 www-data www-data screen.sh
Does anyone work with the macros? Of does anyone have another idea how to call my script file upon motion detection.
Many thanks
Running as www-data does give extra security to prevent a web operation doing nasty things. You can either add www-data user to groups that are allowed to do the operation or you can be more selective and allow the www-data to perform specific operations. This is actually how the web interface is allowed to do things like reboot and shutdown the system. The install puts a file /etc/sudoers.d/RPI_Cam_Web_Interface which specifies the operation that can be performed. A similar approach could be used to add more commands.