#!/bin/bash
cd /home/work/thermometer
datestr="`date '+%y%m%d-%H%M'`"
temp="`./therm`"
echo $temp | awk '{print $1}' > last.outside
echo $temp | awk '{print $2}' > last.inside

LASTOUT=`echo $temp | awk '{print $1}'`
LASTIN=`echo $temp | awk '{print $2}'`


#display temperatures on supervisory console after acquisition
MOSTTHERM=`curl --max-time 10 -s http://most.mauriceward.com:8077/paint1/history.php|head -n1|cut -b -5`
echo "TEMPS:${LASTOUT}c ${LASTIN}c  ${MOSTTHERM}c    " | nc -u 10.0.0.8 1234


if [ "$LASTOUT" == "144.7" ]; then
  echo "ERROR READING TEMPERATURES: $LASTOUT $LASTIN" | logger -t cron-logtemp
else
  echo $datestr $temp >> therm.log
  ./makegraph
fi
