Skip to content

Instantly share code, notes, and snippets.

@metalrufflez
Created November 21, 2011 13:54
Show Gist options
  • Save metalrufflez/1382672 to your computer and use it in GitHub Desktop.
Save metalrufflez/1382672 to your computer and use it in GitHub Desktop.
Script to parse and mail DHL tracking updates
#!/bin/bash
URL='http://www.dhl.com/content/g0/en/express/tracking.shtml?brand=DHL&AWB=<INSERT_TRACKING_CODE_HERE>%0D%0A'
BULK="$(curl -s "$URL" | egrep -A1 -m1 '<td class=".*" style="width: 5% ;text-align:left">.+</td>' | egrep -o '>.+<' | sed 's/[><]//g')"
CODE="$(echo $BULK | cut -d " " -f1)"
CTLFILE=/root/ctlfile
if [ "$CODE" -ne "$(cat $CTLFILE)" ]; then
echo $CODE > $CTLFILE
mail -s "DHL Update" <INSERT_YOUR_EMAIL_HERE> < <(echo $BULK)
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment