Upon Alarm Detection Execute Shell Command

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

Upon Alarm Detection Execute Shell Command

Post by AnotherBrian » Thu Sep 22, 2011 6:33 pm

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 » Fri Sep 23, 2011 4:34 pm

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
Contact:

Re: Upon Alarm Detection Execute Shell Command

Post by MJN » Tue Sep 27, 2011 12:12 pm

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

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests