Skip to content

Instantly share code, notes, and snippets.

@ryo1kato
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save ryo1kato/e58b4bb2b566008f7305 to your computer and use it in GitHub Desktop.

Select an option

Save ryo1kato/e58b4bb2b566008f7305 to your computer and use it in GitHub Desktop.
surveillanceCamera.sh - script to save pics from web-cam priodically
#!/bin/bash
#
# http://iharder.sourceforge.net/current/macosx/imagesnap/
#
normal_interval_sec=30
cloud_interval=4
save="$HOME/usr/var/SurCam"
save_cloud="$HOME/Dropbox/SurCam"
mkdir -p "$save"
mkdir -p "$save_cloud"
cd "$save"
count=0
while sleep $normal_interval_sec
do
filename="$PWD/$(date +%FT%T).jpg"
imagesnap "$filename"
if (( count++ % cloud_interval == 0 ))
then
echo "Save to cloud: $filename"
( cd "$save_cloud" && ln -s "$filename" ./ )
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment