#!/bin/sh # # Yes I know :), this file name is weather.txt # did not want to use the real name of weather.sh # because I do no know how comcast would like # that name sitting on their site. # # Usually you would execute this via cron # I execute once every 3 hours or so. # Note, the first run of this may seem odd # but after 24 hours it should be OK # # Author: John McCue # Licence: I do not care, whatever # # gets weather data for use in conky # will create multiple files that one # can cat out from conky. So weather # information is 'divorced' from conky # # The only 'non-standard' utility needed is "lynx" # in order to execute this script. # # ---> look for 'Change this for your site' below # ---> to customize for your location. # # gets weather from noaa.gov # gets sunrise/set from gaisma.com # ############################################################################### # clean_up -- cleanup run ############################################################################### clean_up() { rm -f "$out_lock_file" "$mail_msg" "$temp_f1" } # END: clean_up() ############################################################################### # log_msg() -- Log a message to the system logs ############################################################################### log_msg() { lmsg="$1" type logger > /dev/null 2>&1 if test "$?" -ne "0" then return fi logger "$lmsg" } # END: log_msg() ############################################################################### # domail() -- send a mail message ############################################################################### domail() { ecode="$1" mmsg="$2" echo "Date: `date`" > "$mail_msg" echo '' >> "$mail_msg" echo "noaa weather retrieve error from:" >> "$mail_msg" echo " $sname" >> "$mail_msg" echo '' >> "$mail_msg" echo "$mmsg" >> "$mail_msg" echo '' >> "$mail_msg" type mailx > /dev/null 2>&1 if test "$?" -eq "0" then mailx -s "ERROR: $sname" "$USER"@localhost < "$mail_msg" else cat "$mail_msg" fi rm -f "$mail_msg" if test "$mmsg" != "" then log_msg "$mmsg" fi if test "$ecode" != "0" then clean_up exit 2 fi } # END: domail() ############################################################################### # trap_found -- trap (CTL)C ############################################################################### trap_found() { clean_up domail "2" "WARNING W05: script cancelled" } # END trap_found() ############################################################################### # check_exec -- check for an executable ############################################################################### check_exec() { pname="$1" type $pname > /dev/null 2>&1 if test "$?" -ne "0" then domail "2" "ERROR E03: program $pname missing" fi } ############################################################################### # have_net() -- determine if a netwrok connection is active # Sets var have_network to "Y" or "N" ############################################################################### have_net() { have_network=`/sbin/ifconfig | grep 'inet addr:' | grep -v 'inet addr:127\.0\.0\.1' | wc -l` if test "$have_network" -ge "1" then have_network="Y" return fi have_network=`/sbin/ifconfig re0 2> /dev/null | grep 'inet ' | grep -v 'inet addr:127\.0\.0\.1' | wc -l | sed 's/ //g'` if test "$have_network" -ge "1" then have_network="Y" return fi have_network=`/sbin/ifconfig xl0 2> /dev/null | grep 'inet ' | grep -v 'inet addr:127\.0\.0\.1' | wc -l | sed 's/ //g'` if test "$have_network" -ge "1" then have_network="Y" return fi } # have_net() ############################################################################### # ck_noaa() -- verify noaa, bypass processing if NA is returned # for current conditions ############################################################################### ck_noaa() { na_found=`sed 's/^ *//;s/ *$//' $ofile | grep '^Humidity:' | head -n 1 | awk '{print $2}'` if test "$na_found" = "NA" then domail "2" "ERROR E07: noaa returned N/A for Humidity" fi na_found=`sed 's/^ *//;s/ *$//' $ofile | grep '^Wind Speed:' | head -n 1 | awk '{print $2}'` if test "$na_found" = "NA" then domail "2" "ERROR E08: noaa returned N/A for Wind Speed" fi na_found=`sed 's/^ *//;s/ *$//' $ofile | grep '^Barometer:' | head -n 1 | awk '{print $2}'` if test "$na_found" = "NA" then domail "2" "ERROR E09: noaa returned N/A for Barometer" fi na_found=`sed 's/^ *//;s/ *$//' $ofile | grep '^Dewpoint:' | head -n 1 | awk '{print $2}'` if test "$na_found" = "NA" then domail "2" "ERROR E10: noaa returned N/A for Dewpoint" fi na_found=`sed 's/^ *//;s/ *$//' $ofile | grep '^Visibility:' | head -n 1 | awk '{print $2}'` if test "$na_found" = "NA" then domail "2" "ERROR E11: noaa returned N/A for Visibility" fi } # END: ck_noaa() ############################################################################### # cp_out() -- copy a file for use by conky ############################################################################### cp_out() { conky_fname="$1" if test -f "$cdir/$conky_fname" then rm "$cdir/$conky_fname" fi if test -f "$odir/$conky_fname" then cp "$odir/$conky_fname" "$cdir/$conky_fname" chmod 644 "$cdir/$conky_fname" fi } # END: cp_out() ############################################################################### # bsdfmt() -- format using non-GNU (bsd) tools # newlines need to be excaped, fmt has a different meaning # for -c ############################################################################### bsdfmt() { sed 's/^Sunday/|Sunday/' $out_forecast_raw \ | sed 's/^Today/|Today/' \ | sed 's/^Tonight/|Tonight/' \ | sed 's/^Monday/|Monday/' \ | sed 's/^Tuesday/|Tuesday/' \ | sed 's/^Wednesday/|Wednesday/' \ | sed 's/^Thursday/|Thursday/' \ | sed 's/^Friday/|Friday/' \ | sed 's/^Saturday/|Saturday/' \ | sed 's/\.\.\./ /g' \ | sed 's/ */ /g' \ | sed 's/ /\ /g' \ | sed 's/^ *//;s/ *$//' \ | awk '{printf("%s ", $1)}' \ | sed 's/^|//' \ | sed 's/|/\ /g' \ | sed 's/^/\ \ \* /' \ | fmt -c -w 50 \ | sed 's/^/ /' \ | sed 's/^ \*/\*/' \ | fmt -w 57 \ | grep -v '^$' \ | sed 's/^/ /;s/^ *\*/\*/' \ >> $out_forcast_fmt } # END: bsdfmt() ############################################################################### # linfmt() -- format using GNU tools ############################################################################### linfmt() { sed 's/^Sunday/|Sunday/' $out_forecast_raw \ | sed 's/^Today/|Today/' \ | sed 's/^Tonight/|Tonight/' \ | sed 's/^Monday/|Monday/' \ | sed 's/^Tuesday/|Tuesday/' \ | sed 's/^Wednesday/|Wednesday/' \ | sed 's/^Thursday/|Thursday/' \ | sed 's/^Friday/|Friday/' \ | sed 's/^Saturday/|Saturday/' \ | sed 's/\.\.\./ /g' \ | sed 's/ */ /g' \ | sed 's/ /\n/g' \ | sed 's/^ *//;s/ *$//' \ | awk '{printf("%s ", $1)}' \ | sed 's/^|//' \ | sed 's/|/\n/g' \ | sed 's/^/\n\n\* /' \ | fmt -c -w 50 \ | sed 's/^/ /' \ | sed 's/^ \*/\*/' \ | fmt -c -w 60 \ | grep -v '^$' \ >> $out_forcast_fmt } # END: linfmt() ############################################################################### ############################################################################### # main ############################################################################### ############################################################################### sname="$0" rmode="$1" if test "$OS" = "" then OS=`uname -s` fi #--- 'Change this for your site', these default # New York City. # To get your noaa (weather) WEB site, type your # zip code into the search and select "GO" -- # after pasting the URL below. # The gaisma WEB site seems easy to use. url='http://forecast.weather.gov/MapClick.php?CityName=New+York&state=NY&site=OKX&lat=40.7198&lon=-73.993' url_sun='http://www.gaisma.com/en/location/new-city-ny.html' #--- Change this, used to hold files retrieved via lynx # dirs will be created if missing hdir=$HOME/.weathern #--- from here down should NOT need to change cdir=$hdir/conky odir=$hdir/noaa ofile=$odir/raw_noaa.txt raw_sun=$odir/raw_sun.txt mail_msg=$odir/temp.mail.msg out_temperature=$odir/out.degrees out_temperature_low=$odir/out.degrees.low out_temperature_high=$odir/out.degrees.high out_temperature_fmt=$odir/out.degrees.fmt out_dew=$odir/out.dew out_alerts=$odir/out.alerts out_humid=$odir/out.humid out_wind=$odir/out.wind out_last_upd=$odir/out.last_upd out_barometer=$odir/out.barometer out_barometer_old=$odir/out.barometer.old out_barometer_trend=$odir/out.barometer-direction out_visibility=$odir/out.visibility out_conditions=$odir/out.conditions out_lock_file=$odir/lock.out.file out_forcast_fmt=$odir/out.fmt.forecast out_stat_today=$odir/out.stats.today out_stat_forecast=$odir/out.stats.forecast out_mail=$odir/out.mail.prn out_complex=$odir/out.weather.prn now_sunrise=$odir/out.sunrise now_sunset=$odir/out.sunset now_sunlength=$odir/out.day_length now_sun_stat=$odir/out_sun.stats temp_f1=$odir/temp_file_1 out_forecast_raw=$odir/out.raw.forecast out_forecast_3=$odir/out.forecast-3-30 out_forecast_3a=$odir/out.forecast-3-40 out_forecast_4=$odir/out.forecast-4-40 out_forecast_5=$odir/out.forecast-5-50 out_forecast_6=$odir/out.forecast-6-60 out_forecast_7=$odir/out.forecast-6-60 out_forecast_8=$odir/out.forecast-6-60 out_forecast_9=$odir/out.forecast-6-60 out_forecast_10=$odir/out.forecast-6-60 trap trap_found SIGINT SIGTERM ############################################################################### # create dirs if not found ############################################################################### if test ! -d "$hdir" then mkdir "$hdir" fi if test ! -d "$cdir" then mkdir "$cdir" fi if test ! -d "$odir" then mkdir "$odir" fi ############################################################################### # verify ############################################################################### if test ! -d "$odir" then domail "2" "ERROR E01: dir $odir missing" fi if test -f "$out_lock_file" then domail "2" "ERROR E02: lock file exists $out_lock_file, bailing" fi date > "$out_lock_file" dnow=`date '+%Y-%m-%d'` ############################################################################### # add paths, some crons do not allow environment variables settings ############################################################################### if test -d "/usr/local/bin" then PATH="$PATH:/usr/local/bin" fi if test -d "/opt/jmc/bin" then PATH="$PATH:/opt/jmc/bin" fi if test -d "/usr/games" then PATH="$PATH:/usr/games" fi ############################################################################### # check for programs, probably not needed, but.... ############################################################################### check_exec lynx check_exec awk check_exec head check_exec tail check_exec sed check_exec grep check_exec cp check_exec rm check_exec expr check_exec cat check_exec fmt check_exec stat check_exec /sbin/ifconfig ############################################################################### # is the network available ? # if not error out ############################################################################### have_net if test "$have_network" = "N" then domail "2" "ERROR E04: cannot find active network, aborted" fi ############################################################################### # get current data from the web ############################################################################### if test "$rmode" != "TEST" then rm -f "$ofile" lynx -accept_all_cookies -dump "$url" > "$ofile" & fi ck_noaa if test "$rmode" = "TEST" then get_sun="N" else get_sun="N" if test -f "$now_sun_stat" then oldsun=`stat $now_sun_stat | grep 'Change:' | awk '{print $2}'` if test "$dnow" != "$oldsun" then get_sun="Y" fi else get_sun="Y" fi fi if test "$get_sun" = "Y" then lynx -accept_all_cookies -dump "$url_sun" > "$raw_sun" fi wait if test ! -s "$ofile" then domail "2" "ERROR E06: lynx failed, $ofile not created" fi ############################################################################### # First get some values, also does a secondary nooa validation # -- sometimes ck_noaa may miss some NA # does not need to know degree display type ############################################################################### #--- Humidity humid_na=`grep 'Humidity:' "$ofile" \ | awk '{print $2, $3}' \ | sed 's/^ *//;s/ *$//' \ | grep '^[-0123456789]'` if test "$humid_na" = "NA" then domail "2" "ERROR E12: noaa returned N/A for Humidity" fi if test "$humid_na" = "" then domail "2" "ERROR E15: noaa returned N/A for Humidity" fi grep 'Humidity:' "$ofile" \ | awk '{print $2, $3}' \ | sed 's/^ *//;s/ *$//' \ | grep '^[-0123456789]' > $out_humid #--- Wind Speed wind_na=`grep 'Wind Speed:' "$ofile" \ | sed 's/Wind Speed://' \ | sed 's/^ *//;s/ *$//'` if test "$wind_na" = "NA" then domail "2" "ERROR E13: noaa returned N/A for Wind Speed" fi if test "$wind_na" = "" then domail "2" "ERROR E16: noaa returned N/A for Wind Speed" fi grep 'Wind Speed:' "$ofile" \ | sed 's/Wind Speed://' \ | sed 's/^ *//;s/ *$//' > $out_wind #--- Visibility visi_na=`grep 'Visibility:' "$ofile" \ | sed 's/Visibility://' \ | sed 's/^ *//;s/ *$//'` if test "$visi_na" = "NA" then domail "2" "ERROR E14: noaa returned N/A for Visibility" fi if test "$visi_na" = "" then domail "2" "ERROR E17: noaa returned N/A for Visibility" fi grep 'Visibility:' "$ofile" \ | sed 's/Visibility://' \ | sed 's/^ *//;s/ *$//' > $out_visibility ############################################################################### # Degree logic -- save low and high temp ############################################################################### found_degf="Y" deg_text="°F" cond_line=0 #--- Current Temp -- must be first to set variable found_degf grep DEGF "$ofile" | sed 's/^ *//;s/ *$//' \ | sed 's/DEGF//;s/ //g' | grep '^[-0123456789]' > $out_temperature if test -s "$out_temperature" then cond_line=`grep -nh DEGF "$ofile" | head -1 | awk 'BEGIN{FS=":"}{print $1}'` cond_line=`expr $cond_line - 1` else found_degf="N" grep '°F' "$ofile" | sed 's/^ *//;s/ *$//' \ | sed 's/DEGF//;s/ //g' | grep '^[-0123456789]' \ | sed 's/°F//' > $out_temperature if test -s "$out_temperature" then cond_line=`grep -nh '°F' "$ofile" | head -1 | awk 'BEGIN{FS=":"}{print $1}'` cond_line=`expr $cond_line - 1` fi fi #--- create base low temp for today if test -f "$out_temperature_low" then oldb=`stat $out_temperature_low | grep 'Change:' | awk '{print $2}'` newb=`stat $out_temperature | grep 'Change:' | awk '{print $2}'` if test "$oldb" != "$newb" then cp -p $out_temperature $out_temperature_low fi else cp -p $out_temperature $out_temperature_low fi #--- create base high temp for today if test -f "$out_temperature_high" then oldb=`stat $out_temperature_high | grep 'Change:' | awk '{print $2}'` newb=`stat $out_temperature | grep 'Change:' | awk '{print $2}'` if test "$oldb" != "$newb" then cp -p $out_temperature $out_temperature_high fi else cp -p $out_temperature $out_temperature_high fi #--- determine / save low and high if test ! -s "$out_temperature_low" then cp -p $out_temperature $out_temperature_low fi if test ! -s "$out_temperature_high" then cp -p $out_temperature $out_temperature_high fi tnew=`cat $out_temperature` tlow=`cat $out_temperature_low` thigh=`cat $out_temperature_high` if test "$tnew" -lt "$tlow" then cp -p $out_temperature $out_temperature_low fi if test "$tnew" -gt "$thigh" then cp -p $out_temperature $out_temperature_high fi #--- create formatted temp echo `cat $out_temperature`"°F" -- Low/High: `cat $out_temperature_low`"°/"`cat $out_temperature_high`"°" > $out_temperature_fmt ############################################################################### # extract get current conditions for use in conky ############################################################################### #--- last Update grep 'Last Update on' "$ofile" \ | sed 's/Last Update on//' \ | sed 's/^ *//;s/ *$//' > $out_last_upd #--- Dew Point if test "$found_degf" = "Y" then grep 'Dewpoint:' "$ofile" \ | awk '{print $2}' \ | sed 's/^ *//;s/ *$//' \ | grep '^[-0123456789]' > $out_dew else grep 'Dewpoint:' "$ofile" \ | awk '{printf("%s%s", $2, $3)}' \ | sed 's/^ *//;s/ *$//' \ | grep '^[-0123456789]' > $out_dew fi #--- get current condition line if test "$cond_line" -gt "0" then head -"$cond_line" $ofile \ | tail -1 | sed 's/^ *//;s/ *$//' > "$out_conditions" else echo "" > "$out_conditions" fi ############################################################################### # Barometer logic, allows us to see trend since the start of the day ############################################################################### if test -f "$out_barometer_old" then oldb=`stat $out_barometer_old | grep 'Change:' | awk '{print $2}'` newb=`stat $out_barometer | grep 'Change:' | awk '{print $2}'` if test "$oldb" != "$newb" then rm -f $out_barometer_old fi fi #--- Save old (if necessary) if test ! -f "$out_barometer_old" then cp -p "$out_barometer" "$out_barometer_old" fi #--- get current Barometer grep 'Barometer:' "$ofile" \ | sed 's/Barometer://' \ | sed 's/^ *//;s/ *$//' \ | awk '{print $1}' > $out_barometer #--- format trend if test -f "$out_barometer_old" then cat "$out_barometer_old" "$out_barometer" \ | fmt \ | sed 's/ / --> /' \ > "$out_barometer_trend" else cp -p "$out_barometer" "$out_barometer_trend" fi ############################################################################### # get forecast start/end line numbers ############################################################################### fstart="" fstart_01="1" fstart_02="1" fstart_03="1" fstart_04="1" fstart_05="1" fstart_06="1" fstart_07="1" fstart_08="1" fstart_09="1" fstart_10="1" rm -f "$out_alerts" #--- try and find start of forecast and save alerts lfound=`sed 's/^ *//;s/ *$//' $ofile | grep -n '^Detailed text forecast$' | wc -l` if test "$lfound" -eq "1" then fstart_01=`sed 's/^ *//;s/ *$//' $ofile | grep -n '^Detailed text forecast$' | awk 'BEGIN{FS=":"}{print $1}'` fi lfound=`grep -n 'Hazardous weather condition' $ofile | wc -l` if test "$lfound" -eq "1" then fstart_02=`grep -n 'Hazardous weather condition' $ofile | awk 'BEGIN{FS=":"}{print $1}'` fi lfound=`grep -n '\[9\]Wind Advisory' $ofile | wc -l` if test "$lfound" -eq "1" then fstart_03=`grep -n '\[9\]Wind Advisory' $ofile | awk 'BEGIN{FS=":"}{print $1}'` echo '[9]Wind Advisory' >> $out_alerts fi lfound=`grep -n '\[8\]Hazardous Weather Outlook' $ofile | wc -l` if test "$lfound" -eq "1" then fstart_04=`grep -n '\[8\]Hazardous Weather Outlook' $ofile | awk 'BEGIN{FS=":"}{print $1}'` echo '[8]Hazardous Weather Outlook' >> $out_alerts fi lfound=`grep -n '\[9\]Red Flag Warning' $ofile | wc -l` if test "$lfound" -eq "1" then fstart_05=`grep -n '\[9\]Red Flag Warning' $ofile | awk 'BEGIN{FS=":"}{print $1}'` echo '[9]Red Flag Warning' >> $out_alerts fi lfound=`grep -n '\[8\]Winter Storm Watch' $ofile | wc -l` if test "$lfound" -eq "1" then fstart_06=`grep -n '\[8\]Winter Storm Watch' $ofile | awk 'BEGIN{FS=":"}{print $1}'` echo '[8]Winter Storm Watch' >> $out_alerts fi lfound=`grep -n '\[8\]Winter Weather Advisory' $ofile | wc -l` if test "$lfound" -eq "1" then fstart_07=`grep -n '\[8\]Winter Weather Advisory' $ofile | awk 'BEGIN{FS=":"}{print $1}'` echo '[8]Winter Weather Advisory' >> $out_alerts fi lfound=`grep -n '\[8\]Dense Fog Advisory' $ofile | wc -l` if test "$lfound" -eq "1" then fstart_08=`grep -n '\[8\]Dense Fog Advisory' $ofile | awk 'BEGIN{FS=":"}{print $1}'` echo '[8]Dense Fog Advisory' >> $out_alerts fi lfound=`grep -n '\[9\]Hazardous Weather Outlook' $ofile | wc -l` if test "$lfound" -eq "1" then fstart_09=`grep -n '\[9\]Hazardous Weather Outlook' $ofile | awk 'BEGIN{FS=":"}{print $1}'` echo '[9]Hazardous Weather Outlook' >> $out_alerts fi lfound=`grep -n '\[8\]Flood Advisory' $ofile | wc -l` if test "$lfound" -eq "1" then fstart_10=`grep -n '\[8\]Flood Advisory' $ofile | awk 'BEGIN{FS=":"}{print $1}'` echo '[8]Flood Advisory' >> $out_alerts fi #--- now find the higest start line number fstart=$fstart_01 if test "$fstart" -lt "$fstart_02" then fstart=$fstart_02 fi if test "$fstart" -lt "$fstart_03" then fstart=$fstart_03 fi if test "$fstart" -lt "$fstart_04" then fstart=$fstart_04 fi if test "$fstart" -lt "$fstart_05" then fstart=$fstart_05 fi if test "$fstart" -lt "$fstart_06" then fstart=$fstart_06 fi if test "$fstart" -lt "$fstart_07" then fstart=$fstart_07 fi if test "$fstart" -lt "$fstart_08" then fstart=$fstart_08 fi if test "$fstart" -lt "$fstart_09" then fstart=$fstart_09 fi if test "$fstart" -lt "$fstart_10" then fstart=$fstart_10 fi ############################################################################### # format raw forecast data ############################################################################### fstart=`expr $fstart + 1` tlines=`wc -l < $ofile` elines=`expr $tlines - $fstart + 1` sed 's/^ *//;s/ *$//' $ofile \ | tail -"$elines" | head -"$nlines" \ | sed 's/\.\.\./ \.\.\. /g' \ > $out_forecast_raw ############################################################################### # create formatted formats, multiple sizes ############################################################################### fmt -w 30 $out_forecast_raw | head -3 > $out_forecast_3 fmt -w 40 $out_forecast_raw | head -3 > $out_forecast_3a fmt -w 40 $out_forecast_raw | head -4 > $out_forecast_4 fmt -w 50 $out_forecast_raw | head -5 > $out_forecast_5 fmt -w 60 $out_forecast_raw | head -6 > $out_forecast_6 fmt -w 60 $out_forecast_raw | head -7 > $out_forecast_7 fmt -w 60 $out_forecast_raw | head -8 > $out_forecast_8 fmt -w 60 $out_forecast_raw | head -9 > $out_forecast_9 fmt -w 60 $out_forecast_raw | head -10 > $out_forecast_10 ############################################################################### # Generate day sun information ############################################################################### sed 's/^ *//' $raw_sun | grep '^Today' | head -1 \ | awk '{print $2}' > $now_sunrise sed 's/^ *//' $raw_sun | grep '^Today' | head -1 \ | awk '{print $3}' > $now_sunset sed 's/^ *//' $raw_sun | grep '^Today' | head -1 \ | awk '{print $4}' > $now_sunlength echo "Rise: `cat $now_sunrise` Set: `cat $now_sunset` Length: `cat $now_sunlength`" \ > $now_sun_stat ############################################################################### # Generate Formatted forecast ############################################################################### rm -f "$out_forcast_fmt" case "$OS" in "Linux") linfmt ;; "FreeBSD") bsdfmt ;; *) bsdfmt ;; esac ############################################################################### # format current stats ############################################################################### if test "$found_degf" = "N" then deg_text_fmt=" " else deg_text_fmt="$deg_text" fi echo "As of: `cat $out_last_upd` Temperature: `cat $out_temperature`°F -- Low/High: `cat $out_temperature_low`°/`cat $out_temperature_high`° Wind: `cat $out_wind` Visibility: `cat $out_visibility` Humidity: `cat $out_humid` Dewpoint: `cat $out_dew`$deg_text_fmt Barometer: `cat $out_barometer-direction` Sunrise/set: `cat $now_sunrise` -- `cat $now_sunset` Day Length: `cat $now_sunlength`" \ > $temp_f1 type pom > /dev/null 2>&1 if test "$?" -eq "0" then echo " `pom`" | fmt -w 32 >> $temp_f1 fi sed 's/$/ /' $temp_f1 \ | cut -c '1-48' > $out_stat_today rm -f "$temp_f1" ############################################################################### # format forecast ############################################################################### if test -s "$out_conditions" then echo "Current Condition: `cat $out_conditions` -- Forecast: `head -10 $out_forcast_fmt | sed 's/^/ /'` " > $out_stat_forecast else echo "Forecast: `head -10 $out_forcast_fmt | sed 's/^/ /'` " > $out_stat_forecast fi ############################################################################### # format mail file ############################################################################### echo "Weather `date` =========================================================== `cat $out_stat_today` ------------------------------------------------------------ `cat $out_forcast_fmt` ------------------------------------------------------------ ******* End of Report *******" \ | sed 's/ *$//' \ > $out_mail ############################################################################### # format complex conky weather file ############################################################################### sed 's/$/| /' "$out_stat_today" > "$temp_f1" flines=`wc -l < $out_stat_forecast` clines=`wc -l < $out_stat_today` if test "$clines" -lt "$flines" then flines=`expr $flines - $clines` clines=0 while test "$clines" -lt "$flines" do echo ' | ' >> "$temp_f1" clines=`expr $clines + 1` done fi paste "$temp_f1" "$out_stat_forecast" \ | sed 's/\t//' \ > $out_complex rm -f "$temp_f1" ############################################################################### # copy files for use by conky ############################################################################### if test -d "$cdir" then cp_out out.barometer cp_out out.barometer-direction cp_out out.barometer.old cp_out out.conditions cp_out out.day_length cp_out out.degrees cp_out out.degrees.fmt cp_out out.degrees.high cp_out out.degrees.low cp_out out.dew cp_out out.fmt.forecast cp_out out.forecast-3-30 cp_out out.forecast-3-40 cp_out out.forecast-4-40 cp_out out.forecast-5-50 cp_out out.forecast-6-60 cp_out out.humid cp_out out.last_upd cp_out out.mail.prn cp_out out.raw.forecast cp_out out.stats.forecast cp_out out.stats.today cp_out out.sunrise cp_out out.sunrise_tomorrow cp_out out.sunset cp_out out.visibility cp_out out.weather.prn cp_out out.wind cp_out out_sun.stats fi ############################################################################### # Done ############################################################################### clean_up if test "$rmode" != "TEST" then log_msg "SUCCESS: Weather information retrieved via $sname" fi exit 0