Quick script to check if a domain is about to expire

A couple of nights ago I threw together a quick script to be able to do some automatic checks to see if my domains are expiring. The script is full of ugly code but it gets the job done and I can now loop through a list of domains. Example of usage below.
%sh domain-checker.sh
This script requires two options: domain and number of days.
ex:
domain-checker.sh foo.com 20

%sh domain-checker.sh henrikandersen.se 300
Domain henrikandersen.se expires in less than 300 days! (104 days)

%sh domain-checker.sh henrikandersen.se 100
If the domain expires in less then the given number of days you will be alerted, if not the script exits with 0. Just uncomment the row with #echo ${RESULT} in the end to always display the days if you like it better.

It uses a temporary file that is not deleted afterwards and could have been skipped altogether but the idea was to in the future add some checks to see if it was from the current day and if so not do the whois query to at least avoid some abuse of the whois system. It is unclear if that will happen. Written and tested on FreeBSD YMMV. Anyway,┬áif you like it or have any feedback I’d love to know.

Get it here: domain-checker.sh
SHA256: 67e5906a75703ad46f3dae5d9bf999d5a514fd6a6285bfddfe4a9b29c782b7d5

Share

Leave a Reply

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