Skip to content

Instantly share code, notes, and snippets.

@bonetechnologies
Created February 8, 2014 00:04
Show Gist options
  • Save bonetechnologies/8874508 to your computer and use it in GitHub Desktop.
Save bonetechnologies/8874508 to your computer and use it in GitHub Desktop.
#!/bin/bash
COUNTIES="clackamas multnomah washington"
#Get the pages and print it via STDOUT.
#HTTP_GET_COMMAND="wget -qO- "
HTTP_GET_COMMAND="curl -s "
ALL_OUTAGES_NUM=0
for county in $COUNTIES;
do
echo -n "${county}: "
OUTAGES_NUM=$(${HTTP_GET_COMMAND} http://www.portlandgeneral.com/safety_outages/outages/outage_updates/outage_detail.aspx\?county\=${county} | grep "ctl00_ctl00_GlobalContentWell_ZContentWell_rptCountyDetail" | grep Customers | awk -F"Customers\">" '{ print $2 }' | sed 's/\<.*$//g'| awk '{total = total + $1}END{print total}')
ALL_OUTAGES_NUM=`expr $OUTAGES_NUM + $ALL_OUTAGES_NUM`
echo ${OUTAGES_NUM}
done
echo "-------------------------"
echo "total: ${ALL_OUTAGES_NUM} customers without power."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment