redbr64
Posts: 7
Joined: Fri Jan 12, 2018 11:42 pm

Motion Event Macro on RPi Cam Web interface

Mon May 21, 2018 6:45 am

I have been using RPi Cam Web Interface for a while, but I am now trying to use the macros but running into problems. I am trying to run the motion_event macro. I have followed the docs (https://elinux.org/RPi-Cam-Web-Interface#Job_Macros) and this tutorial (https://quavoce.wordpress.com/2017/06/0 ... interface/). The logs say that the macro is being executed, but nothing results from it. I have tested running the bash script on the command line and it works fine, but not when rpi_cam_web_interface tries to run it. I am posting a snippet from the log, and then also my steps to get there.

Any ideas are appreciated! Thanks!

LOG SNIPPET:
{2018/05/21 06:17:23} Set up internal detect width=121 height=68
[2018/05/21 06:17:38] Logged in user::
[2018/05/21 06:17:38] UserLevel 6
{2018/05/21 06:17:41} Executing macro /var/www/html/macros/motion_event.sh "1"
{2018/05/21 06:17:41} send smd 1
[2018/05/21 06:17:41] Start capture requested from Pipe
[2018/05/21 06:17:41] Send ca 1
{2018/05/21 06:17:41} Capturing started
{2018/05/21 06:17:49} Executing macro /var/www/html/macros/motion_event.sh "0"
{2018/05/21 06:17:49} send smd 0
[2018/05/21 06:17:49] Stop capture requested
[2018/05/21 06:17:49] Send ca 0
{2018/05/21 06:17:49} Capturing stopped
{2018/05/21 06:17:49} Add /var/www/html/media/vi_0002_20180521_061741.mp4 to Box Queue at pos 15
{2018/05/21 06:17:50} Start boxing /var/www/html/media/vi_0002_20180521_061741.h264 to /var/www/html/media/vi_0002_20180521_061741.mp4 Queue pos 15
{2018/05/21 06:17:51} Finished boxing /var/www/html/media/vi_0002_20180521_061741.mp4 from Box Queue at pos 15
{2018/05/21 06:17:51} Removed item from Box Queue
MY STEPS TO REPRODUCE:

Code: Select all

sudo nano /var/www/html/macros/motion_event.sh

Code: Select all

#!/bin/bash
echo "some data for the file" >> testmacro.txt
please note that what I actually want to do is use aplay to play a sound and then send some pipe commands to change the look of the video - it is for an art performance, just keeping it simple for test purposes. Regardless, even this simple doesn't work, although the script works when run from the terminal as pi user

Code: Select all

sudo chmod -x /var/www/html/macros/motion_event.sh
sudo chown www-data:www-data /var/www/html/macros/motion_event.sh sudo chmod 764 /var/www/html/macros/motion_event.sh

redbr64
Posts: 7
Joined: Fri Jan 12, 2018 11:42 pm

Re: Motion Event Macro on RPi Cam Web interface

Mon May 21, 2018 7:40 pm

an update on the last post - the problem was that I did not specify a full path for the text file. the script does run indeed. But I am still having some trouble with my ultimate goal, which is to play a sound and then send some pipe commands. So here is what I did so far, and it does not play the sound, and sometimes causes RPi Cam Web Interface to crash (the UI remains, but stops working)


1) Changed the script to this:

Code: Select all

#!/bin/bash
aplay /var/www/html/macros/beep.wav
echo "played sound" >> /var/www/html/macros/testmacro.txt
2) Gave ownership of beep.wav to www-data

Code: Select all

sudo chown www-data:www-data /var/www/html/macros/beep.wav
3) Still didn't work, so also tried this:

Code: Select all

sudo chmod 764 /var/www/html/macros/beep.wav
Any ideas? it seems maybe I need to give www-data the ability to run aplay, but not sure how to do it... visudo something?

redbr64
Posts: 7
Joined: Fri Jan 12, 2018 11:42 pm

Re: Motion Event Macro on RPi Cam Web interface

Mon May 21, 2018 11:37 pm

Got the problem above solved by Robert's help in github - the solution was to add a permission to run /usr/bin/aplay command in the /etc/sudoers.d/RPI_Cam_Web_Interface file.

Return to “Camera board”

Who is online

Users browsing this forum: No registered users and 7 guests