#!/bin/bash
#
# pusher.sh - shell script to watch the data directory on c1.chess.cornell.edu
#             and push any new data files that show up there up to the
#             destination account and directory shown below.  Only files that
#             are newer than the one given as an argument are sent.
#

destination_account=jonesrt@zeus.phys.uconn.edu
destination_dir=/home/www/docs/halld/diamonds/chess-4-2011/data/Si331/

if [ $# -lt 1 ]; then
  echo "Usage: pusher.sh <reference file>"
  exit 1
elif [ ! -f $1 ]; then
  echo "Error: file $1 not found"
  exit 1
fi

scp $1 $destination_account:$destination_dir
while true; do
  sleep 10;
  for f in `find . -newer $1`; do
    scp $f $destination_account:$destination_dir
  done
done
