#!/bin/bash OVERVIEW_URL="https://ec.europa.eu/consumers/consumers_safety/safety_products/rapex/alerts/?event=main.weeklyReports.XML" TEMP_OUT=/tmp/temp TEMP_MAIL=/tmp/temp_mail # Download XML curl -s -o $TEMPOUT $OVERVIEW_URL # grep newest CURRENT_URL=`grep -A 1 '' $TEMP_OUT | head -2 | tail -1` # Download newest curl -s -o $TEMP_OUT $CURRENT_URL # grep Images IMG_URLS=`grep -A 1 '' $TEMP_OUT | awk -F [ '{ print $3 }' | sed 's/.\{3\}$//' | sed '/^$/d' | sed 's/\(.*\)/\1/'` # generate html template cat > $TEMP_MAIL < European Commission - Rapid Alert System - Weekly Reports $IMG_URLS EOL # sendemail mail -a "Content-type: text/html;" -s "European Commission - Rapid Alert System - Weekly Reports" my@email.com < $TEMP_MAIL # clean up rm $TEMP_OUT rm $TEMP_MAIL