I may not be smart, but I make up for it by being the biggest damn ham in the blogosphere.

Weather Forecast From the Command Line

Date/Time Permalink: 02/02/09 05:35:42 am
Category: Reviews

For years, I've been getting my weather from Firefox plug-ins, usually ForecastFox. The trouble with these is they have to update every few minutes, causing a brief lag in bandwidth and even a small blip in performance if you're using some other program while Firefox is running. Recently, my ForecastFox started misbehaving for no particular reason. It would blank out and freeze up and so on.

So I decided to uninstall it for now and explore alternatives. True, I could just bookmark the local news weather page and be done with it. But I like something that would run in the background, use the minimum of resources, and not be dependent on running a web browser. So I explored command-line options.


The first I found is weather-util, a Python script done by a formidable fellow who is geek enough to have affinities for Linux, HURD, and OpenBSD all at once.

Despite the INSTALL instructions telling me to put the Python module here and the man pages there, I just plonked the whole directory in my Python subfolder and call it with a three-liner shell script, so it can stay together in one place and still be treated like an install program.

In my case the command line is

./weather -i KDSM -c "Des Moines" -s IA -f

...for Des Moines, Iowa. And follow the instructions in 'FAQ' and you, too, will know what your four-letter METAR code is.


I also stumbled on a script called "weather" on my Slackware system. It's in /usr/bin/, and it's a Tcl/Expect script that uses telnet to put weather data. Yes, you heard me, telnet. I had no idea telnet even worked anymore! The only clue to the script's origin is a comment at the beginning:

# weather - Expect script to get the weather (courtesy University of Michigan)
# Don Libes
# Version 1.10

...and leave it to Slackware to have something like this lurking around. Anyway, I went root and edited the line:

if {$argc>0} {set code $argv} else {set code "WBC"}

Changing WBC to DSM for Des Moines... which was a completely lucky guess.

The Wicked-Cool shell script option

Since I have a copy of No-Starch Press's "Wicked Cool Shell Scripts", I'll go ahead and mention this script which checks Accu-Weather from the command line. I remember trying it on another box a while back and I seem to recall it worked OK there.

The only problem with any of these is that there's a minute lag in getting the data. This could be solved, if I get that picky, by setting a cron job to run the script every hour or so and save it to a text file for easy catting.

Now while we're on the command line, it'd be nice if somebody drew an ASCII map of the state:

    |                                  |                          |            
    |                                  |  MS                       )            
    /                                  |                          [             
   |                                   |                          [            
   |                                  I35                          ---         
    \              SL                  |                              \       
     [                         FD     /           CF                   \-\      
     [                                |            WL                     \    
      \                               |                                    \   
       \                             AM      MT             CR              \ 
        |                             |                                     ] 
        \                             |                                      ] 
         \                            |        ______________IC_____________/   
          \             ___I80________DM______/                       DP----   
           |___________/            |                               ---/       
           |                        |                              [            
           |CB                      |                               ]          
            \                       |              OW               ]          
            |                       |                              /           
            \                       |                             /            
             \______________________________________________     /             

And then somebody else could come up with a way to make the radar map be ASCII too, and you could just represent the precipitation with clouds of #'s rolling across the map...

Oh well, that would be *too* geeky.

Update 1/5/10 This old post no longer applies, as I now run Ubuntu and run a Gnome panel applet for weather info. However, here's the latest thing in command line weather, this time with RSS and PHP. The torch has been passed!

Follow me on Twitter for an update every time this blog gets a post.
Stumble it Reddit this share on Facebook

suddenly the moon