Commit 2478ad6f by Fred Smith

get the weather using google's weather api. takes a zipcode and spits

out the current condidions and the forecast for the next few days.

This is a mess and I hate it, but it works.
parent ff001e0e
#! /bin/bash
LONG="false";
if [[ "$1" -eq "" ]]; then
ZIPCODE="01720";
else
ZIPCODE="$1";
LONG="true";
fi
LINECOUNT="0";
curl -s "http://www.google.com/ig/api?weather=$ZIPCODE" | sed -e 's/.*city/city/' -e 's/\/>/\n/g' | grep -e 'city' -e '<condition data' -e '<temp_f' -e 'high' -e 'day_of_week' | cut -f 2 -d '"' |
while read LINE; do
LINECOUNT=$(( $LINECOUNT + 1));
#echo -n "$LINE ";
if [ $LINECOUNT -eq 1 ]; then
export CITY=$LINE;
elif [ $LINECOUNT -eq 2 ]; then
export CONDITIONS=$LINE;
elif [ $LINECOUNT -eq 3 ]; then
export TEMP=$LINE;
elif [ $LINECOUNT -eq 4 ]; then
export DAY1=$LINE;
elif [ $LINECOUNT -eq 5 ]; then
export DAY1TEMP=$LINE;
elif [ $LINECOUNT -eq 6 ]; then
export DAY1COND=$LINE;
elif [ $LINECOUNT -eq 7 ]; then
export DAY2=$LINE;
elif [ $LINECOUNT -eq 8 ]; then
export DAY2TEMP=$LINE;
elif [ $LINECOUNT -eq 9 ]; then
export DAY2COND=$LINE;
elif [ $LINECOUNT -eq 10 ]; then
export DAY3=$LINE;
elif [ $LINECOUNT -eq 11 ]; then
export DAY3TEMP=$LINE;
elif [ $LINECOUNT -eq 12 ]; then
export DAY3COND=$LINE;
elif [ $LINECOUNT -eq 13 ]; then
export DAY4=$LINE;
elif [ $LINECOUNT -eq 14 ]; then
export DAY4TEMP=$LINE;
elif [ $LINECOUNT -eq 15 ]; then
export DAY4COND=$LINE;
$LONG && echo "$CITY - $TEMP' - $CONDITIONS ----- $DAY1: $DAY1COND $DAY1TEMP', $DAY2: $DAY2COND $DAY2TEMP', $DAY3: $DAY3COND $DAY3TEMP'" || echo "$TEMP' - $CONDITIONS";
fi
done;
# Acton, MA
#Overcast
#40
#Fri
#52
#Chance of Storm
#Sat
#59
#Mostly Sunny
#Sun
#72
##Clear
#Mon
#79
#Partly Sunny
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment