#!/usr/bin/perl -w use strict; my $alarm = '/var/local/scr/alarm'; die "$0 camx /path/to/dest\n" if (not $#ARGV eq 1); my $cam = $ARGV[0]; my $destpath = $ARGV[1]; my ($dir, $file) = $destpath =~ m#(.*)/(.*)#; my $lock="/tmp/$cam.lock"; die "Can't get lock for $cam\n" if (system("/usr/local/bin/shlock -p $$ -f $lock")); # http my $imgdl = 'IMAGE.jpg'; my $cam1_url = "http://$cam.svh.merlins.org/$imgdl"; # motion my $img_src = "/var/www/html/camcapt/$cam/motion/lastsnap.jpg"; chdir($dir) or die "Can't cd to $dir: $!\n"; if (not system("ps auxww | grep -q '[0-9] motion'")) { #warn("Grabbing from $cam via motion snapshot at ".`date --rfc-3339=ns`); system("cp $img_src $file"); #warn("Done Grabbing from $cam via snapshot at ".`date --rfc-3339=ns`); } else { #warn("Grabbing from $cam via wget at ".`date --rfc-3339=ns`); system("$alarm 3 wget --quiet --user=pict --password=pictpwd -O $imgdl $cam1_url; mv $imgdl $file"); #warn("Done Grabbing from $cam via wget at ".`date --rfc-3339=ns`); } unlink($lock);