I am trying to implement a solution for automatic mail sending once it finds a domain that expiration date has been exceeded. I am really new to this, therefore I managed to get as far as code below, that shows expiration dates and sends an email containg the output.
The kind of help I am looking for is at least a clue how to compare expiration date with the current date and get a result as number of days. I will really appreciate any kind of help.
#!/bin/bash
DOM="onet.pl wp.pl"
for d in $DOM
do
echo -n "$d - "
whois $d | egrep -i 'Expiration|Expires on' | head -1
whois $d | egrep -i 'Expiration|Expires on' | head -1 >> /tmp/domain.date
echo ""
done
#[ -f /tmp/domain.date ] && mail -s 'Domain renew / expiration date' myemail@gmail.com < /tmp/domain.date || :