#!/bin/bash # program myforecast # version 1.0 # written by Andrew V. Newman # last modified Tue Feb 24 17:21:57 MST 2004 # shell script to bring up a weather forecast either on a # graphical browser or in the console if the screen is not available. # Create a default location. This assumes you live in the US as I do. CITY=Los_Alamos # use underscore to separate multi-word cities STATE=NM # Sets a default URL BASE URL_SUF=US/$STATE/$CITY.html # Set the default graphical browser # I like galeon, but it may not be installed on your machine. GUI_BROWSER=/usr/bin/konqueror GUI_BROWSER=/usr/bin/galeon GUI_BROWSER=/usr/bin/mozilla # ---------------------------- # # Shouldn't have to change these LYNX=/usr/bin/lynx URL_BASE=http://www.wunderground.com/ MBL_URL_BASE=http://mobile.wunderground.com/ # If you use just one variable if [ $1 ] ; then URL_SUF=cgi-bin/findweather/getForecast?query=$1 fi # If you use two variables if [ $2 ]; then CITY=$1 STATE=$2 URL_SUF=US/$STATE/$CITY.html fi # If you can display a window on your terminal it will # bring up your forecast in a graphical browser if [ $DISPLAY ]; then URL=${URL_BASE}${URL_SUF} $GUI_BROWSER $URL 2> /dev/null # Otherwise, it will bring it up on screen using a version # of the website set up for mobile computers (no ads and few graphics, # which will not be displayed anyway). else URL=${MBL_URL_BASE}${URL_SUF} $LYNX $URL -dump 2> /dev/null >forecast.temp # displays forecast as text more forecast.temp # remove temporary file rm forecast.temp fi # exit cleanly exit 0