Shell script to email when web page has updates/changed

Some shipping companies don’t have any sort of notification system for when updates happen to packages. For small things, this is probably not a major issue, but when i ordered my huge Patio roof, i needed to be at home when it was being delivered to help unload.

Unfortunately the website did not have any notifications, and the alternative was to hit reload on the page all the time to check. I figured this should be easy to script and so wrote this small shell script to watch the page, and email me if there were any updates

 

#!/bin/bash
#
# URL to check
url="http://fasttracker-nz.tollgroup.com/onetoll-fast-tracker.aspx?ConsignmentNumber=xxxxxxxxxx"
 
# Temp file to store the tracking page
temp=/tmp/trackingcheck
 
# Get the page, remove dynamic content of newrelic and diff feedback on that
modified=$(wget -q -O $temp $url ; diff ${temp} ${temp}.1 |grep -v newrelic |grep -v --  "--" |grep -v 8c8 )
 
# This is a good idea if it has the Last Modified headers, but in my case it didn't
#modified=$(curl -sI "$url" | grep ^Last-Modified)
 
# set email address
email="liz@xxxxxx.com"
 
# Check if the modified variable exists and is more than 0 characters
if [[ ! -z "$modified" && ${#modified} -gt 0 ]]; then
    # Email me the changes if there are any
    echo $url has changed  $modified  - modified| mail -s "Tracking Update"  ${email}
    # Copy the recent grab of the page to the second file to compare to next time
    cp ${temp} ${temp}.1
fi

The initial idea was to check for Last-Modified headers, but they did not have those, so i ended up dumping the page to /tmp/trackingcheck and comparing against /tmp/trackingcheck.1 . I had to adapt my diff command to remove the newrelic dynamic content lines, which probably could have been done, but over all the script worked nicely.
I set up a cron task to run that every 10 minutes. If the page has changed, it emails me, and copies the temp file to /tmp/trackingcheck.1

*/10 * * * * /home/velofille/tracking.sh

40 years of marriage… Be careful what you wish for – joke/humour

Came via email from several sources:

A married couple in their early 60s was celebrating their 40th wedding anniversary in a quiet, romantic little restaurant.
Suddenly, a tiny yet beautiful fairy appeared on their table. She said, ‘For being such an exemplary married couple and for being loving to each other for all this time, I will grant you each a wish.’
The wife answered, ‘Oh, I want to travel around the world with my darling husband’.
The fairy waved her magic wand and – poof! – two tickets for the Queen Mary II appeared in her hands.
The husband thought for a moment: ‘Well, this is all very romantic, but an opportunity like this will never come again. I’m sorry my love, but my wish is to have a wife 30 years younger than me’.
The wife, and the fairy, were deeply disappointed, but a wish is a wish.
So the fairy waved her magic wand and poof!…the husband became 92 years old.
The moral of this story: Men who are ungrateful bastards should remember fairies are female….