Skip to content

Instantly share code, notes, and snippets.

@acetwenty8
Created July 31, 2016 14:01
Show Gist options
  • Save acetwenty8/86788743f16770858513582eb775bcea to your computer and use it in GitHub Desktop.
Save acetwenty8/86788743f16770858513582eb775bcea to your computer and use it in GitHub Desktop.
#!/bin/bash
#ESBcolor2email.sh
#@acetwenty8 7/31/2016
#Script to send an email if ESB is not signature white tonight
TEMP=/tmp/`date +%s`.tmp
EML=/tmp/`date +%s`.eml
EMAILADDR=somewhere@nowhere.com
HTML=`curl -sq http://www.esbnyc.com/explore/tower-lights > $TEMP`
TODAY=`cat $TEMP | perl -ne 'print if s/\s+?<h1.*>(.*)<\/h1>/$1/g'`
TOMORROW=`cat $TEMP | tr -d '\n' | perl -ne 'print if s/.*<strong>Tomorrow<\/strong><p>(.*?)<\/p>.*/$1/g'`
YESTERDAY=`cat $TEMP | tr -d '\n' | perl -ne 'print if s/.*<strong>Yesterday<\/strong><p>(.*?)<\/p>.*/$1/g'`
echo $TODAY | grep -qi "signature white"
RV=$?
if [[ $RV -ne 0 ]]; then
#It's not white tonight
echo $TODAY
echo Tonight: $TODAY >> $EML
echo Tomorrow: $TOMORROW >> $EML
echo Yesterday: $YESTERDAY >> $EML
cat $EML | mail -s "ESB Color Tonight" $EMAILADDR
else
echo $TODAY
fi
rm -rf $TEMP
rm -rf $EML
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment