Notify on cbr.ru rates change

script for cron:

#!/bin/bash
TOMMOROW=$(date +"%d.%m.%Y" --date="next day")
touch /var/tmp/cbr.log # just so that it exist
curl http://cbr.ru/currency_base/D_print.aspx?date_req=01.01.2099 |\
sed 's/Курсы валют за 01.01.2099 не зарегистрированы\.//' |\
sed '/<!--/,/-->/d' |\
sed '/<script/,/<\/script>/d' > /tmp/cbr.html

if [ -z `cat /var/tmp/cbr.log | grep "$TOMMOROW"` ]
then
   if [ -n `cat /tmp/cbr.html | grep "$TOMMOROW"` ]
   then
      echo "$TOMMOROW" > /var/tmp/cbr.log
      echo "Курсы во вложении"| mutt me@example.com -s "ЦБР обновил курс!" -a /tmp/cbr.html
   fi;
fi;
This entry was posted in Linux. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *