#!/bin/bash
# weather-mail 20060810rm
#
# Put this script on /usr/local/share/weather-mail
# Create a symlynk /usr/local/bin/weather-mail -> /usr/local/share/weather-mail/weather-mail
# Script will create a file called weather.txt in /usr/local/share/weather-mail then mail it
# to $ADDRESSEE from $SENDER
# Run this as a cron job
# You can do a different script for diffent addresses or remove variable $ADDRESSEE and use
# multiple mail commands with a different addressee in each one.

TMP_DIR=/usr/local/share/weather-mail/
ADDRESSEE=[email address]
SENDER=[email address]

# Start of with a header
  echo "##############################################################################" > $TMP_DIR/weather.txt
  echo "# With compliments of       ......PUT YOUR BUSINESS NAME HERE!......" >> $TMP_DIR/weather.txt
  echo "##############################################################################" >> $TMP_DIR/weather.txt
   
# Use lynx to dump the web page as a file
   lynx -dump www.bom.gov.au/cgi-bin/wrap_fwo.pl?IDV17102.txt > $TMP_DIR/.weather.txt

# Use sed to cut out the parts we want
   sed -n '/Central/,/Geelong/ p' $TMP_DIR.weather.txt | sed -e '/Geelong/ d' >> $TMP_DIR/weather.txt
   sed -n '/Yarra Glen/,/Mornington/ p' $TMP_DIR.weather.txt | sed -e '/Mornington/ d' >> $TMP_DIR/weather.txt

# Provide current phase of the moon. You will need pom from bsd-games
   echo -e "\n`/usr/games/pom` \n\n" >> $TMP_DIR/weather.txt

# Run fortune and add as Thought for the day. You will need fortune from bsd-games
   echo -e "Thought for the day:" >> $TMP_DIR/weather.txt
   echo -e "`/usr/games/fortune` " >> $TMP_DIR/weather.txt

   echo -e "\n\n\n" >> $TMP_DIR/weather.txt
   echo -e "###########################################################################" >> $TMP_DIR/weather.txt
   echo -e "# This is an automated email that is sent out as a courtesy every work" >> $TMP_DIR/weather.txt
   echo -e "# day morning at 06:10 hours. Weather will continue on Saturdays and" >> $TMP_DIR/weather.txt
   echo -e "# Sundays without out the benifit of this email being sent out to you." >> $TMP_DIR/weather.txt
   echo -e "# If you don't like this forecast, see if you can do any better yourself at" >> $TMP_DIR/weather.txt
   echo -e "# http://www.bom.gov.au/cgi-bin/wrap_fwo.pl?IDV17102.txt" >> $TMP_DIR/weather.txt
   echo -e "# To subcribe to this list mail to weather@turtlespond.net with \"subscribe\"" >> $TMP_DIR/weather.txt
   echo -e "# as the subject. If you want to unsubscribe  .........lot's of luck mate!" >> $TMP_DIR/weather.txt
   echo -e "###########################################################################" >> $TMP_DIR/weather.txt
   echo -e "\n" >> $TMP_DIR/weather.txt
   ddate +'%{%A, the %e of %B%}, %Y %N%nCelebrate %H' >> $TMP_DIR/weather.txt

# Now send out the weather report to email addresses as in the command below
   mail -s weather -r $SENDER $$ADDRESSEE < $TMP_DIR/weather.txt


# End of script
