#!/bin/bash # Job Seeker # Joshua Olson # Description: Periodically check the MTU website for new Job Postings. # Usage: Change RECIPIENT variable if necessary. Place in cron at desired # interval. RECIPIENT="${USER}@mtu.edu" SUBJECT="New job posting" TODAY=`date +"%Y%m%d-%H%M"` FORMAT=0 case "$1" in "-h") echo "Checks for new MTU job postings and sends result to $RECIPIENT. Usage: $0 [-f] -f apply formatting prior to mailing recipient (potentially buggy) -h this help screen " exit ;; "-f") FORMAT=1 ;; *) ;; esac if [ -f /tmp/jobs.known ] then /usr/bin/elinks -dump -no-numbering \ "http://www.admin.mtu.edu/hro/postings/index.shtml" \ > /tmp/jobs.$TODAY /usr/bin/diff /tmp/jobs.$TODAY /tmp/jobs.known > /tmp/jobs.diff COUNT=`wc -l /tmp/jobs.diff | awk '{print $1}'` if [ $COUNT -ge 1 ] then if [ $FORMAT -eq 1 ] then echo "FORMAT" sed -n '/JOB POSTINGS/,/Minorities and women/p' \ < /tmp/jobs.$TODAY | Mail -s "$SUBJECT" $RECIPIENT else echo "NO FORMAT" Mail -s "$SUBJECT" $RECIPIENT < /tmp/jobs.$TODAY fi cp /tmp/jobs.$TODAY /tmp/jobs.known fi rm -f /tmp/jobs.$TODAY else /usr/bin/elinks -dump -no-numbering \ "http://www.admin.mtu.edu/hro/postings/index.shtml" \ > /tmp/jobs.known echo "Job Seeker initiated." fi # ChangeLog # # * Mon Sep 17 2007 Joshua Myles - 99.6 # - Changed $RECIPIENT to use $USER environment variable # # * Mon Sep 17 2007 Joshua Myles - 99.5 # - Refactored case logic to be easier to follow # - Fixed formatting of usage screen # # * Mon Sep 17 2007 Joshua Olson - 99.4 # - Replaced switch check with case statement # - Added -h help switch # # * Mon Sep 17 2007 Joshua Myles - 99.3 # - Fixed inconsistent information at top of script # - Cats are smelly # # * Mon Sep 17 2007 Joshua Olson - 99.2 # - Added switch for optional sed formatting of mail message # - Bug fix: 00002 - rm may delete files not associated with this script # # * Mon Sep 17 2007 Joshua Myles - 99.1 # - Added -no-numbering # - Added simple cleaning of mailed message # - Added clean-up for old jobs.* files # - Bug fix: 00001 - current jobs file not copied to jobs.known when new # # * Mon Sep 17 2007 Joshua Olson - 99.0 # - Initial revision.