Security System with Hazel

From your noodle to other noodles. Talk about ways to get the most from Hazel. Even exchange recipes for the cool rules you've thought up. DO NOT POST YOUR QUESTIONS HERE.

Moderators: Mr_Noodle, Moderators

Security System with Hazel Tue Sep 30, 2008 9:31 am • by a_freyer
This is a first post for me, although I have been using hazel for as long as I have had my MBP.

Hazel Security:
Needed: Hazel, DropBox (of http://www.getdropbox.com), isightcapture shell script, laptop/desktop with iSight built in

DropBox is just a great backup tool, and for me it is a perfect solution. Essentially, it automatically syncs folders and files on any computer with any other computer connected anywhere. There are many other services that do this, but the idea is the same.


Steps:
Setup Hazel to monitor a file name. I have set mine to monitor a file named "RemotePic - OFF.txt" so that when I change OFF to ON it triggers the rule.
When the rule is matched, run the following shell script:
Code: Select all
for ((i=0; i<=5;i++))
do
date=$(date +%y%m%d%H%M%S).jpg
/Applications/Utilities/isightcapture $date
sleep 1
done


This will take 5 time stamped pictures of whoever is using the computer and upload them via dropbox.

The best part is that since dropbox and hazel are constantly operating, the pictures are taken on average only 30 seconds after I change the filename on another computer. Uploaded another 15 after that.

If this computer ever gets stolen, I can have a pic of the thief in the first minute s/he is on the internet.
Last edited by a_freyer on Sun Oct 04, 2009 12:09 pm, edited 1 time in total.
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: Security System with Hazel Tue Oct 07, 2008 8:52 am • by a_freyer
recently, I also added a screen shot feature to this setup. Still works really fast, although uploading a screenshot at full resolution takes some time.
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: Security System with Hazel UPDATED Wed Sep 30, 2009 1:31 am • by a_freyer
Dropbox's iPhone app was released today, with the ability to take and upload photos to any directory from the Phone - so I updated this rule, and now its better.

The code is pretty much the same:
Code: Select all
for ((i=0; i<=5;i++))
do
date=$(date +%y%m%d%H%M%S).jpg
/Applications/Utilities/isightcapture $date
sleep 1
done

ifconfig > "Network Dump.txt"


Except I added an IP Address/Network info dump at the end.


The trigger is different though:

(1) Any Filename beginning with "Mobile" {dropbox names all their photos with: "Mobile Photo TIMESTAMP.jpg"}
(2) Execute Shell Script
(3) Rename triggering file {so that we don't trigger over and over and over again}

Obviously, this particular hazel watch folder is also a dropbox sync folder. I have timed the total sequence (with iPhone 3G):

5 seconds (average) to load dropbox app on iPhone and navigate to appropriate directory
11 seconds to take a photo of something random
12 seconds on average for Dropbox to sync back to laptop, and script to run
5 seconds to get the first picture taken from laptop back to phone.

SO - if my laptop gets stolen, and is online somewhere, I can have IP information and 5 photos of the person in front of it within (liberally) 1 minute.... ON MY PHONE.

From another computer, it is MUCH faster.

Anyway, I think this is pretty neat.
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: Security System with Hazel Fri Oct 02, 2009 5:12 pm • by Mr_Noodle
Pretty neat. Where is the isightcapture script though?
Mr_Noodle
Site Admin
 
Posts: 11251
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Security System with Hazel Fri Oct 02, 2009 5:19 pm • by a_freyer
http://www.intergalactic.de/pages/iSight.html

This is a rather old utility, but still works great in 10.6.1
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: Security System with Hazel Mon May 03, 2010 5:35 pm • by theblarney
Hi,

Apologies for re-opening this but I have just got onto this by listening to Mac Power Users and its an awesome idea.

The tutorial works but I have a couple of questions.

Only 1 picture is uploaded to dropbox not 5, also, the Network Dump.txt file is a good idea but I cannot find this on my Mac either.

Im running 10.6.3 so this might be the issue.

Thanks

Gav
theblarney
 
Posts: 3
Joined: Mon May 03, 2010 5:31 pm

Re: Security System with Hazel Mon May 03, 2010 5:41 pm • by a_freyer
Odd. The script still works for me in 10.6.3.

Is hazel moving the other 4 pictures somewhere else?

Are you using an embedded script (correct) or an external script saved as an executable (incorrect)?

Check your Home folder for the NetworkDump.txt?
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: Security System with Hazel Mon May 03, 2010 5:51 pm • by theblarney
a_freyer wrote:Odd. The script still works for me in 10.6.3.

Is hazel moving the other 4 pictures somewhere else?

Are you using an embedded script (correct) or an external script saved as an executable (incorrect)?

Check your Home folder for the NetworkDump.txt?


No I was using an external script but...

I have changed it to an embedded script and now the Network Dump file appears and the trigger renames but now no images are posted.
theblarney
 
Posts: 3
Joined: Mon May 03, 2010 5:31 pm

Re: Security System with Hazel Mon May 03, 2010 5:59 pm • by a_freyer
is the "isightcapture" utility in /Applications/Utilities?

Otherwise, you'll have to change that path to reflect where it is on your computer.
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: Security System with Hazel Mon May 03, 2010 6:08 pm • by theblarney
a_freyer wrote:is the "isightcapture" utility in /Applications/Utilities?

Otherwise, you'll have to change that path to reflect where it is on your computer.


Perfect, thanks it works a treat now.
theblarney
 
Posts: 3
Joined: Mon May 03, 2010 5:31 pm

Re: Security System with Hazel Wed May 26, 2010 12:45 am • by mojoe2013
this is awesome! thanks for posting this. i just ran a test and noticed that the .txt file it exports only contains your local IP i.e. 192.168.1.XXX. is there anyway to have it include your ip from beyond the router that might be more of a help to police to locate the thief? thanks again!
mojoe2013
 
Posts: 8
Joined: Wed Sep 02, 2009 5:51 pm

Re: Security System with Hazel Wed May 26, 2010 12:54 am • by a_freyer
you could dump the arp table too:

ifconfig > "Network Dump.txt"
arp -a > "Network Dump.txt"
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: Security System with Hazel Thu May 27, 2010 1:58 am • by mojoe2013
Thanks for the quick reply! I added the: arp -a > "Network Dump.txt" and it does dump some more data to the text file, but still not my external ip, only a variety of internal IPs (192.168.1.XXX and 10.211.55.255 and 10.37.129.255). Any ideas on how to get it to dump my external ip? Thanks so much for your help!
mojoe2013
 
Posts: 8
Joined: Wed Sep 02, 2009 5:51 pm

Re: Security System with Hazel Thu May 27, 2010 2:12 am • by a_freyer
By adding this line, you should be able to see your external iIP too:

curl -s http://checkip.dyndns.org | sed 's/[a-zA-Z/<> :]//g' > "Network Dump.txt"
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: Security System with Hazel Tue Jan 18, 2011 12:48 pm • by Zettt
Hey there,

Really nice approach! I had one problem, though. imagecapture doesn't get updated, as mentioned here, and it caused troubles on my system. I have another webcam driver installed and imagecapture always uses that camera even when setting a different camera index (as imagecapture calls it. Use -h option)
I was struggling a bit and then found ImageSnap. They claim to have a newer version than imagecapture. The tool does the same thing, but rather than using any cam that's there, it uses the built-in iSight in the first place.

Also I would recommend to install ImageSnap to a different place. I went with /opt/local/bin.
Zettt
Zettt
 
Posts: 30
Joined: Wed Aug 29, 2007 8:50 am

Next

Return to Tips & Tricks - DO NOT POST QUESTIONS

cron