Results 1 to 3 of 3

Thread: Weather Script help

  1. #1
    Join Date
    Jun 2009
    Beans
    4

    Weather Script help

    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
    Code:
    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?
    Last edited by yoshi445511; April 28th, 2010 at 10:33 PM. Reason: Wrong Section

  2. #2
    Join Date
    Jun 2007
    Location
    Porirua, New Zealand
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Weather Script help

    Threads merged & tidied.

    Please do not start multiple threads on the same question.
    Forum DOs and DON'Ts
    Please use CODE tags
    Including your email address in a post is not recommended
    My Blog

  3. #3
    Join Date
    Feb 2010
    Location
    Silicon Valley
    Beans
    1,898
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: Weather Script help

    You need to append a colon to indicate that the -z option takes an argument.
    Code:
    while getopts "z:" OPTION; do

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •