|
#!/usr/local/bin/ksh
#################################################################################
# Script weather #
# Description Access internet website to get forcast for the next two days so #
# a decision can be made regarding whether the lawn sprinklers #
# run or not. #
# Written On 06/23/04 #
# Written By Rick Mortensen #
# Modifications #
#################################################################################
# Program Variables
bkdate=/bin/bkdate
awk=/usr/bin/awk
nawk=/usr/local/bin/nawk
lynx=/usr/local/bin/lynx
htod=/home/bin/htod
dtoh=/home/bin/dtoh
DAYMINUS30=`$bkdate -d30 '+%y%m%d'`
YESTERDATE=`$bkdate -d1 '+%m/%d'`
YESTERDAY=`$bkdate -d1 '+%y%m%d'`
DATE=`date '+%m/%d'`
DATENTIME=`date '+%m/%d/%y %H:%M'`
DAY=`date '+%y%m%d'`
SERIAL=`date '+%y%m%d%H%M%S'`
# Directory Variables
WDIR=/tmp
# Website Variables
http=http://
site=www.wrh.noaa.gov/
page=cgi-bin/wrhq/TotalForecast.csh?TotalForecast+WR+WA+007
HITEMP=`$lynx -dump $http$site$page | awk ' / TACOMA / {getline;print $1 "\n" $2 "\n" $3 "\n" $4|"sort"}'|tail -1`
HIPRECIP=`$lynx -dump $http$site$page| awk ' / TACOMA / {getline;print $5 "\n" $6 "\n" $7 "\n" $8|"sort"}'|tail -1|sed 's/%//'`
# File Variables
TMP1=/tmp/weather.tmp1.$$
TMP2=/tmp/weather.tmp2.$$
TMP3=/tmp/weather.tmp3.$$
TMP4=/tmp/weather.tmp4.$$
TEMPFILE=$WDIR/.hitemp
PRECIPFILE=$WDIR/.precip
DATEFILE=$WDIR/.date
# Functions
# Action
echo $DATENTIME
echo "$DATENTIME " > $DATEFILE
echo Highest Predicted Temp for Next Two Days
echo $HITEMP
echo "$HITEMP " > $TEMPFILE
echo Highest Precipitation Probability for Two Days
echo $HIPRECIP
echo "$HIPRECIP " > $PRECIPFILE
# Cleanup
rm -fr $TMP1* $TMP2* $TMP3* $TMP4*
# Extra Commands
#echo Average High Temp for Next Two Days
#$lynx -dump $http$site$page | awk ' / TACOMA / {getline;print ($2+$4)/2}'
#echo Precipitation Probability
#$lynx -dump $http$site$page | awk ' / TACOMA / {getline;print ($5+$6+$7+$8)/4"%"}'
|