nixCraft Poll

Topics

Domain Expiration Check Shell Script

Posted by Vivek Gite [Last updated: October 19, 2007]

I've already written about a shell script to check / monitor domain renew / expiration date here. Now I’ve modified matt’s domain-check script to support additional C/TLDs .in, .biz, .org and .info domains. I've also added 5 seconds delay to avoid whois server rejecting query. This script checks to see if a domain has expired. It can be run in interactive and batch mode, and provides facilities to alarm if a domain is about to expire in advance.

Sample usage

Display expiration date and registrar for theos.in domain:
domain-check-2 -d {domain-name}

$ domain-check-2 -d theos.in
Output:

Domain                              Registrar         Status   Expires     Days Left
----------------------------------- ----------------- -------- ----------- ---------
theos.in                            et4India (R7-AFIN Valid    28-Oct-2009   799  

You can also get an email if theos.in going to expire in 30 days
$ domain-check-2 -a -d theos.in -q -x 30 -e vivek@nixcraft.com

However most killer feature is you can read list of domain names from a file such as mydomains.txt (list each domain on a new line):
$ domain-check-2 -a -f mydomains.txt -q -x 30 -e vivek@nixcraft.com
OR
$ domain-check-2 -f mydomains.txt

Output:

Domain                              Registrar         Status   Expires     Days Left
----------------------------------- ----------------- -------- ----------- ---------
theos.in                            et4India (R7-AFIN Valid    28-Oct-2009   799
nixcraft.org                        oDaddy.com, Inc.  Valid    13-Aug-2009   723
vivekgite.com                       MONIKER ONLINE SE Valid    18-aug-2010   1093
cyberciti.biz                                         Valid    30-Jun-2009   679
nixcraft.info                       oDaddy.com Inc. ( Valid    26-Jun-2009   675
nixcraft.net                        GODADDY.COM, INC. Valid    11-dec-2009   843  

Download

=> Download modified domain-check-2 script here.

Quick installation

Use wget command to download and install domain-check script:
$ wget http://www.cyberciti.biz/files/scripts/domain-check-2.txt
$ mv domain-check-2.txt domain-check
$ chmod +x domain-check
$ ./domain-check -d vivekgite.com

Make sure your run domain-check script using a cron job.

Want to stay up to date with the latest Linux tips, news and announcements? Subscribe to our free e-mail newsletter or RSS feed to get all updates. You can Email this page to a friend.

You may also be interested in other helpful articles:

Discussion on This Article:

  1. Nate Says:

    but… it doesnt work with things like .co.nz domains…

  2. vivek Says:

    Nate,

    You need to modify script to work with .co.nz. I’ve modified as per my requirements. Basically you need to know whois server name for all .nz domain and date format. Let me know those thing and I can tell you the rest

  3. mali Says:

    realy good works thanks a lot vivek

  4. Mark Says:

    I’ve hacked the script to work somewhat with Nagios.
    Does anyone want it?

  5. vivek Says:

    Sure post the script / url / link. If you don’t have a website just email me the script :)

  6. James House Says:

    This script works much better than some of the others on the net. Thanks!

  7. kendall Says:

    I can’t get the script to work for me. I get the following error:
    -bash: domain-check: command not found

  8. vivek Says:

    kendall,

    Did you renamed the script? Did you setup executable permission? Did you run script as:

    ./domain-check -d vivekgite.com
  9. kendall Says:

    thank you for your quick responce. that fixed my problem. and the script works, but it does not flag .ca domains very well. it seems to skip a few such as beelineweb.ca

  10. kendall Says:

    what I mean by skipped, is that is says unknown, but when I look it up manualy it showes that the domain is valid

  11. kendall Says:

    are there any additions to the script that I can put in so it e-mails out when it finds an “unknown” domain?

  12. Java tutorials Says:

    Its great script. does any one know similar php script?

  13. dave Says:

    Mark: Would love to grab a copy of your Nagios version of script! Can you post a link or something? Thanks a bundle.

  14. vivek Says:

    dave,

    I’m not sure if mark can get your message.

  15. fenris Says:

    # Mark Says: September 4th, 2007 at 2:50 pm

    I’ve hacked the script to work somewhat with Nagios.
    Does anyone want it?

    email me or post the url, thanks

  16. Norman Says:

    if date format is that then script will not work

    Renewal-Date: 2008/11/20
    Date-Approved: 2006/11/20
    Date-Modified: 2007/10/21

    give falst output, how to overcome that.

  17. bbobbo Says:

    i suggest you look at the perl NET::DRI package. it can be a bit of bear to install with all of its dependencies, but once you get it working, it’s quite nice. look at their example whois.pl script.

  18. milan1980 Says:

    very nice script. I noticed u accidently hardcoded awk in the code instead of ${AWK} on the line that looks at “Domain Expiration Date”. You could add switches to display other info (i.e. owner, etc…) in case one would want a more detailed report. Either way, nice and easy to use! good job!

  19. Tushar P.Ambekar Says:

    Very…Very Very nice script… but I want something more..I’m sure you can do it. The script should also show the nameservers update date..it’ll be a good idea..isn’t it?

    Regards,
    Tushar

  20. Jonny Says:

    Very nice script - please give me a link or email address to obtain the nagios version of it

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Tags: , , , , , , ,

Copyright © 2004-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.