first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / scripts / x_win / webcam_snagger.sh
1 #!/bin/bash
2
3 # the file name to be found on the remote site is expected to be named
4 # using the prefix and suffix below.
5 # example: prefix=webcam and suffix=jpg leads to a picture named webcam.jpg
6 FILE_PREFIX=webcam
7 FILE_SUFFIX=jpg
8
9 # this is the location on the internet (or local network) where the file
10 # can be found.
11 #WEBPIX_SITE='http://gruntose.com/'
12 WEBPIX_SITE='ftp://velma/incoming'
13
14 # this points at the directory where the downloaded pictures will be stored.
15 WEBPIX_DIR=$HOME/pix_webcam
16 if [ ! -d $WEBPIX_DIR ]; then mkdir $WEBPIX_DIR; fi
17 # make sure that the directory creation worked.
18 if [ ! -d $WEBPIX_DIR ]; then 
19   echo "The target directory $WEBPIX_DIR cannot be created."
20   exit 51;
21 fi
22
23 # the number of seconds to sleep between snapshots of the source file.
24 SNOOZE_PERIOD=3
25
26 # our loop variable.  if you want the numbers that are added to the name to
27 # start at a different value, then change that here.
28 index=1
29
30 while [ $index -lt 10000 ]; do
31   # grab the file and store it to a local location.  
32   chewed_index=$index
33 #hmmm: would be nice to have the numbers prefixed by zeros.
34   if [ $chewed_index -lt 1000 ]; then chewed_index=0$chewed_index; fi
35   if [ $chewed_index -lt 100 ]; then chewed_index=0$chewed_index; fi
36   if [ $chewed_index -lt 10 ]; then chewed_index=0$chewed_index; fi
37
38   wget -i $WEBPIX_SITE/$FILE_PREFIX.$FILE_SUFFIX -o $WEBPIX_DIR/$FILE_PREFIX$chewed_index.$FILE_SUFFIX
39
40   index=$(expr $index + 1)
41   sleep $SNOOZE_PERIOD
42 done
43