MLUG Bash Scripting Workshop 25/04/08 | ||
---|---|---|
Prev | Index | Next |
It's impossible to hear a weather forecast on the radio when you want one. The BOM's website is great but to get there I have to open a browser and point and click my way to the weather for my locality.
My get-forecast script gives us the most recent Mornington Penninsula weather forecast in .35 to .45 of a second after I type get-forecast and hit enter
This will be the last section of this presentation and I thought you might like to customise this script for your locality. I'll give you a screenshot and the relevant section out of the script below and then I'll explain how it works and how you can modify get-forecast for your own local forecast.
# Provide date, time, etc. but use echo so we don't return to a prompt echo -e "`date`\n" # Pipe webpage from lynx to grep and get the date/time issued lynx -dump www.bom.gov.au/cgi-bin/wrap_fwo.pl?IDV17102.txt | grep Issued # Make some space echo "" # Pipe webpage from lynx to sed # Use sed to get everything after Mornington and pipe it to sed which removes # everything after [27] and pipes what's left to more. # More is used to display text in the terminal. lynx -dump www.bom.gov.au/cgi-bin/wrap_fwo.pl?IDV17102.txt | \ sed -n '/Mornington/,/\[27\]/ p' | sed -e '/\[27\]/ d' | more # Uncomment the following line if you have BSD-games pom installed # and you want to include the current phase of the moon. echo -e "`pom` \n\n"