Originally posted by Mekanik
Quote:
if you have internet access, then add this to your ~/.bashrc to have the 10-day forcast displayed,

Code:
get_weather() {
printf "Your 10 Day Weather Forcast as follows:\n"
printf " Date High / Low (°F) Precip %%\n"
lynx -dump "http://www.w3.weather.com/weather/print/XXXXX" | sed -n '/%$/s/\[.*\]//p'
printf " \n"
}
Quote:
where XXXXX is your Zip code
Originally posted by jbsnakeCode:
lynx -dump "http://www.w3.weather.com/weather/print/30127" | sed -n '/%$/s/\[.*\]//p'
printf " \n"
}
i changed the above line of code to read
Code:
lynx -dump "http://www.w3.weather.com/weather/print/$1"
that way i could type:
Code:
get_weather 90210
and get different areas

o yea...on a side note...did weather.com change anything, cause it just doesn't work anymore

might be my network configuration...but nothing else seems affected (and no...it's not the coding changes

)
Originally posted by Mekanikyeah, they were doing some funky java coding and broke the
code earlier today. even direct access to the URL was toast from a browser. i was having the same problems, but it's been fixed for like the past 3hrs.
*note* make sure to include the
sed portion of the script or you won't get the decent ascii output...
here's an update rev,
since you can't use
exit's in your functions because it'll log you out, here's one that you can use to dynamically validate the ZIP and extract the forecast data.
Code:
forecast() {
_ZIP=$1
if [ $# = 1 ];then
printf "$_ZIP\n" | egrep '^[0-9][0-9][0-9][0-9][0-9]$' >>/dev/null
if [ $? = 0 ];then
printf "Your 10 Day Weather Forecast as follows:\n";
lynx -dump "http://www.weather.com/weather/print/$_ZIP" | sed -n '/%$/s/\[.*\]//p';
printf "\n"
elif [ $? = 1 ];then
printf "Bad ZIP code!\n"
fi
elif [ $# != 1 ];then
printf "You need to supply a ZIP code!\n"
fi
}
-mekanik
here's a patch to set a default ZIP code to extract the
10-day forecast data if you don't specify via the shell...this is also posted on
USALUG...
Code:
--- .forecast1 Tue Feb 01 00:00:00 2005
+++ .forecast2 Tue Feb 01 00:00:00 2005
@@ -11,6 +11,8 @@
printf "Bad ZIP code!\n"
fi
elif [ $# != 1 ];then
- printf "You need to supply a ZIP code!\n"
+ printf "Your 10 Day Weather Forecast as follows:\n";
+ lynx -dump "http://www.weather.com/weather/print/${_ZIP:-XXXXX}" | sed -n '/%$/s/\[.*\]//p';
+ printf "\n"
fi
}
enjoy

,
-mekanik