PDA

View Full Version : Weather Script help



yoshi445511
April 28th, 2010, 10:22 PM
I have a weather script that i need to pass an argument to, and then have curl fetch a URL with that argument variable in it. It doesn't give me any errors, but there is no output.
Here's the script

ZIPCODE=
while getopts "z" OPTION; do
case $OPTION in
z)
ZIPCODE=$OPTARG
;;
esac
done
curl --silent -o weather.html "http://www.wunderground.com/cgi-bin/findweather/getForecast?query="$ZIPCODE"&wuSelect=WEATHER"
grep '<span class="nobr"><span class="b">.*</span>&nbsp;F</span>' weather.html | sed ' s@<span class="nobr"><span class="b">@@' | sed ' s@</span>&nbsp;F</span>@@'

EDIT: Oh, Gosh. I seem to have mistakingly posted in the wrong section. Can an Admin Please close this?

lisati
April 29th, 2010, 01:29 AM
Threads merged & tidied.

Please do not start multiple threads on the same question.

gmargo
April 29th, 2010, 06:29 PM
You need to append a colon to indicate that the -z option takes an argument.


while getopts "z:" OPTION; do