Upon Alarm Detection Execute Shell Command

Forum for questions and support relating to the 1.25.x releases only.
Locked
AnotherBrian
Posts: 112
Joined: Tue Jul 27, 2010 6:36 am

Upon Alarm Detection Execute Shell Command

Post 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?
Alan87i
Posts: 116
Joined: Sun Jul 27, 2008 9:58 am

Re: Upon Alarm Detection Execute Shell Command

Post 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
User avatar
MJN
Posts: 251
Joined: Wed Jan 17, 2007 10:29 am
Location: Wiltshire, UK

Re: Upon Alarm Detection Execute Shell Command

Post 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
Locked