#!/bin/bash

rm *obstacles* >/dev/null
date="$(date +%d-%m-%Y)"

value=`wget "http://www.infotrafic.com/route.php?region=Ouest&link=obstacles.php" 2>/dev/null >/dev/null;lynx --dump  "route.php?region=Ouest&link=obstacles.php"|grep "$date"| egrep "D8|D138|D149|D764|N166"|grep -v "ment termin"|awk  -F "<b>" '{print  $2 $3}'|awk -F "</b>" '{print $1}'| sed 's/ /_/g'`
#value=`wget "http://www.infotrafic.com/route.php?region=Ouest&link=obstacles.php" 2>/dev/null >/dev/null;cat "route.php?region=Ouest&link=obstacles.php"|grep N137|grep -v "ment termin"|awk  -F "<b>" '{print  $2 $3}'|awk -F "</b>" '{print $1}'| sed 's/ /_/g'`
echo $value
if [ -n "$value" ];
then
        json="http://localhost:81/json.htm?type=command&param=udevice&idx=164&nvalue=4&svalue=$value"
        echo "$json"
        curl -i -H "Accept: application/json" $json  
	exit 1
else 
        json="http://localhost:81/json.htm?type=command&param=udevice&idx=164&nvalue=1&svalue=Trafic_sans_probleme"
        #echo "HUM " $json >>/var/log/syslog
        curl -s -i -H "Accept: application/json" $json  
	exit 1
fi

