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?
Upon Alarm Detection Execute Shell Command
-
- Posts: 114
- Joined: Tue Jul 27, 2010 6:36 am
Re: Upon Alarm Detection Execute Shell Command
I did by running a script that tails the message log in ubuntu. for the monitor name and "gone into alarm"
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
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
Many thinks to the members that helps @ at LQ.org
Re: Upon Alarm Detection Execute Shell Command
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.Alan87i wrote:IThe only problem is the message log restarts every day so I have to tell cron to restart the script .
Mathew