Skip to content

Instantly share code, notes, and snippets.

@metalrufflez
Created October 2, 2012 21:30
Show Gist options
  • Save metalrufflez/3823429 to your computer and use it in GitHub Desktop.
Save metalrufflez/3823429 to your computer and use it in GitHub Desktop.
Script to parse and mail DirectLog tracking updates
#!/bin/bash
# This script requirest 2 parameters
# $1 = Tracking Number
# $2 = Your mail address
# Didn't do a if check because I'm fat and lazy, deal with it
URL="http://www.directlog.com.br/track_individual/index.asp?flagOC=&fase=0&tipo=0&numtracking=$1"
BULK="$(curl -s "$URL" | egrep '<b>.*<br></b><br>' | tail -1 | sed -r "s/<(br|\/?b)>//g")"
CTLFILE=/tmp/ctldirect
test -z "$BULK" && exit 1
if [ "$BULK" != "$(cat $CTLFILE)" ]; then
echo $BULK > $CTLFILE
mail -s "DirectLog Update $1" $2 < <(echo $BULK)
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment