Tuesday, December 21, 2010

Simple Weather Bash Script

This simple weather bash script was written with the intention of piping it to a text to speech program such as flite or festival. However, it can be used for any sort of text notification such as printing to the command line or emailing.


#!/bin/sh

# spkweather.sh
# Written by:
# Brandt Daniels
# December 2010

LAT=XX.XXXX
LON=-XXX.XXX

RAW=$(curl -s "http://forecast.weather.gov/MapClick.php?site=SGX&lat=$LAT&lon=$LON&TextType=1")
echo "$RAW" | sed 's/\(.*\)<\/b>\(.*\)
.*/\1\2/;s/.*<.*//g;/^$/d' | head -$1

No comments:

Post a Comment