#!/bin/sh

cd /var/www/
rm index.html?action=snapshot*
wget http://localhost:8080/?action=snapshot -T 3 --tries=2

# if image is captured then make a name for it and store
if [ -e  index.html?action=snapshot* ]; then
echo "image captured"

mv index.html?action=snapshot current.jpg


# upload to cloud
if ping -c 1  barbara320.gotdns.com> /dev/null ;
then    echo " ping OK "
curl -F userfile=@/var/www/current.jpg barbara320.gotdns.com/webcamwr703n/mobilewebcam.php
fi


else
echo "could not get picture"
fi
