Page 1 of 1
Upon Alarm Detection Execute Shell Command
Posted: Thu Sep 22, 2011 6:33 pm
by AnotherBrian
I want to trigger the execution of a command (e.g., C program, shell script, etc) when motion is detected.
Is there an easy way to do this?
Re: Upon Alarm Detection Execute Shell Command
Posted: Fri Sep 23, 2011 4:34 pm
by Alan87i
I did by running a script that tails the message log in ubuntu. for the monitor name and "gone into alarm"
Code: Select all
#!/bin/bash
tail -f /var/log/messages | grep --line-buffered 'frontdoor.*Gone into alarm state' | while read line; do aplay /dog1.wav; done
The only problem is the message log restarts every day so I have to tell cron to restart the script .
Many thinks to the members that helps @ at LQ.org
Re: Upon Alarm Detection Execute Shell Command
Posted: Tue Sep 27, 2011 12:12 pm
by MJN
Alan87i wrote:IThe only problem is the message log restarts every day so I have to tell cron to restart the script .
Check out the man page for your version of tail. There are --retry and --follow-name options which allow you to cater for the logfile rotation.
Mathew