Google Site SearchFN Site Search FN Blog Login FN Blog Login
Site Navigation:
 
 

FUN WITH SHELLS: My Radar; a companion to myforecast

by Andrew Newman (CREATED: 2004-03-02)

This is the third in a series, called "Fun with Shells". The point of these articles will be to not only pass around some increadibly useful simple shells, but also, hopefully encourage people to jump in and either modify these or write their own.

This contribution is an extremely simple bash shell that I wrote for calling up the local doppler radar map (thanks to Wunderground.com. This program is much simpler than the previous shells, as it does not allow for you to call in variables from the command line (this is because the URL that wonderground.com uses here is not entirely straight forward).


Here is the script
#!/bin/bash 
# program myradar
# version 1.0  
# written by Andrew V. Newman
# last modified Tue Tue Mar  2 17:21:01 MST 2004

# shell script to bring up a current local radar

# Sets a default URL BASE 
# NOTE: If you want to change this for your local area, go to 
# wunderground.com and find the correct URL for your area.  
# I modified mine quite a bit so as to only show the gif image
# with the full delay and number of images available.  The only important value
# that needs to be changed to get your area but have it look like mine is the
# "ABX" in my URL path.  For example, switch 'ABX' to 'LOT' to get Chicago. 
URL="http://www.wunderground.com/radar/radblast.asp?num=6&delay=15&noclutter=0&ID=ABX"

# Set the default graphical browser
# I like galeon, but it may not be installed on your machine. 
  GUI_BROWSER=/usr/bin/galeon
# ---------------------------- #
# 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 cannot work for you
  else
        echo "Sorry cannot bring up a display :("
        exit 1
  fi
# exit cleanly
  exit 0

It may be easier to just download a copy (right click).
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 myradar
  • 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
    % mv myradar ~/bin/
    If it is not already there, add the following line to ~/.cshrc if you are using a csh or tcsh shell path = ( $path ~/bin) Or, if you are using bash add the following line to ~/.bashrc PATH=$PATH:~/bin

Ok, if you followed the instructions in the commented area, you should be able to switch the radar image to your area. Ok, now that you have set your defaults, give the program a shot. Try running the following command: % myradar

Please email me if you have any comments or suggestions!