From Steve, 5 Years ago, written in Bash.
  1. #!/bin/bash
  2. #Change to correct directory
  3. cd /home/steve/speed_camera
  4. #Remove previous days files
  5. rm roads suburbs todays_locations *.jsp
  6. #Get latest list
  7. wget http://www.sapolice.sa.gov.au/sapol/road_safety/traffic_safety_camera_locations.jsp
  8. #Define todays name
  9. START=`date +%A`
  10. #Define tomorrow's name
  11. END=`date --date=tomorrow +%A`
  12. #Separate the locations from the rest of the garbage, and trim off the excess source code, outputting into a location list
  13. sed -e '1,/name=\"'$START'\"/d' -e '/name=\"'$END'\"/,$d' traffic_safety_camera_locations.jsp | grep -i td | awk -F '>' '{print $2}' | awk -F '<' '{print $1}' > todays_locations
  14. #Print every second line, starting from line 1 - this is the roads
  15. awk '0 == (NR + 1) % 2'  todays_locations > roads
  16. #Print every second line, starting from line 0 (the first therefore being line 2) - this is the suburbs
  17. awk '0 == NR % 2'  todays_locations > suburbs
  18. #Convert into a more readable format. Truncating the two separate lists together, and separating them by a commar and space, then changing all to lowercase, and capitalising only the first letter
  19. pr -m -t -s\,\  roads suburbs | tr '[:upper:]' '[:lower:]' | sed -e "s/\b\(.\)/\u\1/g" | mail -s "Speed Camera Locations `date +%d/%m/%Y`" email@domain.com