View Single Post
  #1   Report Post  
Old December 12th 05, 09:12 AM posted to alt.talk.weather
B Thomas B Thomas is offline
external usenet poster
 
First recorded activity by Weather-Banter: Dec 2005
Posts: 1
Default Script to obtain weather forecast

Hi,
I wrote a simple script to obtain weather forecast
from a Bash terminal. It is listed below. The
problem with this script is that it is not portable.
A user needs to edit it to make it work for his
geographical location. The script obtains its
information from "National Weather Service",
zone forecasts. For instance the url for columbus,
ohio is

http://www.erh.noaa.gov/displayprod....duct=ILNZFPILN

Would you know how I may generate this url know the user's
zip code or city/state. I mean how can zipcode information
be translated to the weather zone (ILNZFPILN in the above
example). Is there a directory of these somewhere.

regards
b thomas

-------------------------------------------------------------
#!/bin/sh
# forecast - Reports forecast on weather conditions.
# URL must be set to the appropriate value for user
# Also the first multiline sed match string will need
# to be modified (How can this be automated ?)

# For Columbus, Ohio
URL="http://www.erh.noaa.gov/displayprod.php?product=ILNZFPILN"

USAGE="usage: radar [-s filename]
-s save forecast as
-h show this message"

while getopts ":sh" opt
do
case $opt in
s ) SAVE=true;
FILENAME=$OPTARG;;
h|\?) echo "$USAGE"
exit 0 ;;
esac
done

# Scripts has no arguments, this is just for future use
USEDARGS=`expr $OPTIND - 1`
shift $USEDARGS
ARGS="$*"

lynx -dump "$URL" | \
sed -n '/OHZ045-046-054/,/\$\$/p' |\
sed -e 's/\.\.\./\n/' |\
sed -e 's/^\./\n/' |\
sed -e 's/\.\.\.$//' |\
sed -e 's/\.\.\./\n/g' | less
exit 0