myforecast: a companion to myradar
by Andrew Newman
One of a series of example shells:
This contribution is a simple bash shell to call up the weather forecast
What is nice about this shell and the wunderground site, is that you can call up the forecast for just about
anywhere (at least from what I can tell).
# 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
# Sets a default URL BASE
# Set the default graphical browser
# I like galeon, but it may not be installed on your machine.
# ---------------------------- #
# Shouldn't have to change these
# If you use just one variable
if [ $1 ] ; then
# If you use two variables
if [ $2 ]; then
# If you can display a window on your terminal it will
# bring up your forecast in a graphical browser
if [ $DISPLAY ]; then
$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).
$LYNX $URL -dump 2> /dev/null >forecast.temp
# displays forecast as text
# remove temporary file
# exit cleanly
A copy of this script exists in
Once you have a copy on your system, all you need to do is:
- Modify the first two variables to create your own defaults.
- Change permissions of the file so that you can execute it:
% chmod 755 myforecast
- Move file to a directory in your path:
I would suggest creating a bin directory from your home for all
shells and then making certain it is included in your path.
% mkdir ~/bin
If it is not already there, add the following line to ~/.cshrc if you are using a csh or tcsh shell
% mv myforecast ~/bin/
path = ( $path ~/bin)
Or, if you are using bash add the following line to ~/.bashrc
If you look through the program, you will notice that there is a default set up for my old home town. Certainly you
should change to whatever you want. It is important to note here, that though wunderground.com gives forecasts for
cities around the globe, the script is really set to work within the US.
Now that you have set your defaults, give the program a shot. Try running the following commands:
% myforecast Chicago IL
% myforecast Tokyo
% myforecast 30332
Course Home | anewmangatech.edu | Updated:
Mon Sep 18 18:16:49 EDT 2006