#!/usr/bin/env ruby # Copyright (c) 2008 Alexis ROBERT # Under the terms of the BSD license # WARNING ! Only tested with Dell Europe (FR), may not work otherwise. # And well ... btw, it's NOT A CLEAN SOURCECODE ! Be warned : wear glasses ! require 'hpricot' require 'open-uri' require 'digest/md5' require 'net/smtp' SMTP = "" # Your SMTP server MAIL = "" # Your e-mail address URL = "" # Your DELL status page print "Loading #{URL} ...\n" doc = Hpricot(open(URL)) status = doc.search("//form[@name='OrderStatusForm']/table/tr/td")[1].children[1].inner_html print "Status : #{status}\n" # Verifying MD5 status print "Verifying MD5 checksum ... " calc_md5 = Digest::MD5.hexdigest(status) if File.exist?("dell-track.sum") then md5f = open("dell-track.sum","r") saved_md5 = md5f.readlines if saved_md5.length == 0 then saved_md5 = "" # Checksum file is empty else saved_md5 = saved_md5[0].strip end md5f.close else saved_md5 = "" end if saved_md5 == calc_md5 then print "Up to date !\n" exit 0 else md5f = open("dell-track.sum","w") # WARG ! I'm scared ! It's insane ! md5f.write(calc_md5) md5f.close print "NEW !\n" message = < To: #{MAIL} Subject: Dell status changed : #{status} Dell status changed : #{status} Click here if you want to know more about it : #{URL} END_MSG print "Sending mail ... " Net::SMTP.start(SMTP) do |smtp| smtp.send_message message, 'dell-ruby-tracker@dell.com', MAIL end print "OK !\n" exit 1 end