I have already written a shell script to check/monitor domain renew / expiration date here. Now I have modified matty’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 the 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
Sample outputs:
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
Sample outputs:
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
You can setup cron job as follows to get an email notification about domain expiration:
@daily /path/to/script -f /path/to/mydomains.txt -e admin@example.com
Quick installation
Use wget command to download and install domain-check script:
$ wget https://raw.githubusercontent.com/nixcraft/domain-check-2/master/domain-check-2.sh
$ wget https://raw.githubusercontent.com/nixcraft/domain-check-2/master/domain-list.txt
$ sudo mv domain-check-2.sh /usr/local/bin/
$ sudo chmod +x /usr/local/bin/domain-check-2.sh
$ /usr/local/bin/domain-check -d vivekgite.com
Getting help about the script
$ domain-check-2.sh -h
Sample outputs:
Usage: domain-check-2.sh [ -e email ] [ -x expir_days ] [ -q ] [ -a ] [ -h ] {[ -d domain_namee ]} || { -f domainfile} -a : Send a warning message through email -d domain : Domain to analyze (interactive mode) -e email address : Email address to send expiration notices -f domain file : File with a list of domains -h : Print this screen -s whois server : Whois sever to query for information -q : Don't print anything on the console -x days : Domain expiration interval (eg. if domain_date < days)
Make sure your run domain-check-2 script using a Unix/Linux cron jobs. For more info and PR see my github page.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 103 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Hello,
Actually com.ve domains doesn’t work.
Does anyone knows how to fix it ?
.at doesn’t work either.
Tried to write a patch but noticed that server “whois.nic.at” does not return an expiry date.
I’ve noticed that the support for *.link and *.cafe is missing, and I’ve added it to my own script. Is there a github repository that I can push this to in order to help others?
Make sure you use the latest version and ALL PR are welcome https://github.com/nixcraft/domain-check-2
Thank you. I have initiated a pull request with the modifications
Unbale to get the hack to work. I’ve added the line as follows but its throwing an error that it doesn’t understand +%d-%b-%Y`
Can anyone help?
#echo $DOMAINDATE # debug
# Whois data should be in the following format: “13-feb-2006″
IFS=”-”
set — ${DOMAINDATE}
MONTH=$(getmonth ${2})
IFS=””
DOMAINDATE=`date -d ${DOMAINDATE} +%d-%b-%Y`
Grab updated script here:
https://www.cyberciti.biz/files/scripts/domain-check-2_v2.10.txt
Seems my previous post got truncated…
Looks like whois is dates are being returned in the format:
Registry Expiry Date: 2019-06-17T04:00:00Z
Where as the script comments are expecting in this format:
# Whois data should be in the following format: “13-feb-2006”
script will need a retweak to calculate on the new format.
Dirty hack:
add line “DOMAINDATE=`date -d ${DOMAINDATE} +%d-%b-%Y`”
#echo $DOMAINDATE # debug
# Whois data should be in the following format: “13-feb-2006”
DOMAINDATE=`date -d ${DOMAINDATE} +%d-%b-%Y`
Looks like whois is dates are being returned in the format:
Registry Expiry Date: 2019-06-17T04:00:00Z
Where as the script comments are expecting in this format:
# Whois data should be in the following format: “13-feb-2006”
script will need a retweak to calculate on the new format.
I’m getting the same error with all .com domains.
Let me know if anyone finds a fix!
See updated version here
https://www.cyberciti.biz/files/scripts/domain-check-2_v2.10.txt
Try out and let me know.
Since a couple of days the .com extension does not show correctly the expiration date. (it shows expired with -25000, while in fact the domain is still registered).
How to fix?
Hello all,
I am getting output as below which is not correct,
admin@server:~/Desktop$ ./domain-check -d google.com
Domain Registrar Status Expires Days Left
———————————– —————– ——– ———– ———
google.com +1.2083895740 Expired -2457963
admin@server:~/Desktop$ ./domain-check -d sun.com
Domain Registrar Status Expires Days Left
———————————– —————– ——– ———– ———
sun.com +1.2083895740 Expired -2457963
Anyone know why I am getting such reply?
Thanks
Grab updated version and try out:
https://www.cyberciti.biz/files/scripts/domain-check-2_v2.10.txt
How might I tweak this to look for keywords? Like I might want to the look for domains with the keyword food in the .net, .com, .us etc….. how might accomplish this?
That is different. You may need to look into whois function and instead of comparing dates look for keywords.
Has anyone had any luck with a fix for the .org domains returning unknown?
I fixed. .Org and other domains. Try it out and let me know.
http://www.cyberciti.biz/files/scripts/domain-check-2.txt
Thanks for the reply, I actually found what I’m guessing is another version of the script on github that resolved it for me as well.
https://github.com/CHERTS/linux-scripts/blob/master/dns/domain-check.sh
Thanks for script. Based on it i create zabbix check:
https://github.com/Lelik13a/Zabbix-Domain-Check
There’s apparently a new issue with .org domains. I’ve done a partial patch to 2.2 and the output is returning “Unknown” across the board. I know that whois.pir.org made some changes in the past few months that requires a validation/verification code. I’ve also tried swapping out whois.pir.org with whois.publicinterestregistry.net and whois.iana.org to no avail.
Clarifying the “Unknown” point: This is for .org domains. Apologies for missing that.
I added the latest version of this script in your repository https://github.com/CHERTS/linux-scripts/blob/master/dns/domain-check.sh
Anyone can pull request to send change requests.
Hello.
Can anybody help me, i am a beginner, love the function fo this script, but cant get it work
my hoster is Strato. They have online tool, to setup the cron job.
1.) downloaded the script dmain-check-2 and pit it in the root of my ftp (as strato demands) (no file extension; is that correct)
2.) I put 777 on it
3.) as cron exection i pit the command line into the setup of the job:
“” $ domain-check-2 -a -d Domain.com -q -x 30 -e nizzuli@web.de ”
I get unswer: /bin/sh: $: not found or /bin/sh: ./$: not found
I tried everthing without success. Can anybody help me and provide the correct command?
thank you in advance
I tried this on a domain list text file and received this error:
./domain-check: line 150: 12 * 10T01: value too great for base (error token is “10T01”)
Matt’s Bourne shell script was a thing of beauty but has its limitations, which is why I worked with Perl coder Ben Okopnik to reimplement it. Ben’s work is mirrored here:
http://linuxmafia.com/pub/linux/network/domain-check
(See comments in that directory’s 00index.txt file.)
Best,
Rick Moen
rick@linuxmafia.com
Hello, again. I had some time today, so I added both the Russia and Soviet Union TLDs as requested, .ru and .su. The French TLD still doesn’t report expiration to me, which is very odd. I don’t know what that is about.
The folks here at nixcraft haven’t posted my 2.1 version of the script yet, so this patch is to patch version 2.0 (available above) into version 2.2. If you already are running version 2.1, it would be easiest to download 2.0 again, and patch it to 2.2.
— domain-check-2.txt 2014-02-27 15:41:14.000000000 -0500
+++ domain-check-2.2.sh 2014-11-13 15:42:18.498056777 -0500
@@ -4,9 +4,18 @@
#
# Author: Matty
#
-# Current Version: 2.0
+# Current Version: 2.2
#
# Revision History:
+#
+# Version 2.2
+# Bug fix that adds support for .ru and .su domains — Jim McNamara
+#
+# Version 2.1
+# Bug fix for .mobi and .us — Jim McNamara
+# Added a variable for the location of tr, and made all calls to cut and tr use the variable
+# instead of the command without path
+#
# Version 2.0
# Bug fix for .org, .biz, info, and .ca — Cameron and Jim
#
@@ -127,7 +136,9 @@
WHOIS=”/usr/bin/whois”
DATE=”/bin/date”
CUT=”/usr/bin/cut”
-MAIL=”/bin/mail”
+TR=”/usr/bin/tr”
+MAIL=”/usr/bin/mail”
+
# Place to stash temporary files
WHOIS_TMP=”/var/tmp/whois.$$”
@@ -210,7 +221,7 @@
##################################################################
tolower()
{
– LOWER=`echo ${1} | tr [A-Z] [a-z]`
+ LOWER=`echo ${1} | ${TR} [A-Z] [a-z]`
echo $LOWER
}
@@ -226,10 +237,10 @@
sleep 3
# Save the domain since set will trip up the ordering
DOMAIN=${1}
– TLDTYPE=”`echo ${DOMAIN} | cut -d ‘.’ -f3 | tr ‘[A-Z]’ ‘[a-z]’`”
+ TLDTYPE=”`echo ${DOMAIN} | ${CUT} -d ‘.’ -f3 | ${TR} ‘[A-Z]’ ‘[a-z]’`”
if [ “${TLDTYPE}” == “” ];
then
– TLDTYPE=”`echo ${DOMAIN} | cut -d ‘.’ -f2 | tr ‘[A-Z]’ ‘[a-z]’`”
+ TLDTYPE=”`echo ${DOMAIN} | ${CUT} -d ‘.’ -f2 | ${TR} ‘[A-Z]’ ‘[a-z]’`”
fi
# Invoke whois to find the domain registrar and expiration date
@@ -262,6 +273,9 @@
elif [ “${TLDTYPE}” == “com” -o “${TLDTYPE}” == “net” -o “${TLDTYPE}” == “edu” ];
then
${WHOIS} -h ${WHOIS_SERVER} “=${1}” > ${WHOIS_TMP}
+ elif [ “${TLDTYPE}” == “ru” -o “${TLDTYPE}” == “su” ]; # Russia and Soviet Union added 20141113
+ then
+ ${WHOIS} -h “whois.ripn.net” “${1}” > ${WHOIS_TMP}
else
${WHOIS} “${1}” > ${WHOIS_TMP}
fi
@@ -287,6 +301,15 @@
elif [ “${TLDTYPE}” == “ca” ];
then
REGISTRAR=`cat ${WHOIS_TMP} | ${AWK} -F: ‘/Registrar:/ && $0 != “” { getline; REGISTRAR=substr($0,24,17) } END { print REGISTRAR }’`
+ elif [ “${TLDTYPE}” == “mobi” ];
+ then
+ REGISTRAR=`cat ${WHOIS_TMP} | ${AWK} -F : ‘/Updated by Registrar:/ && $2 != “” { REGISTRAR=substr($2,1,17) } END { print REGISTRAR }’`
+ elif [ “${TLDTYPE}” == “us” ];
+ then
+ REGISTRAR=`cat ${WHOIS_TMP} | ${AWK} -F : ‘/Updated by Registrar:/ && $2 != “” { REGISTRAR=substr($2,20,17) } END { print REGISTRAR }’`
+ elif [ “${TLDTYPE}” == “ru” -o “${TLDTYPE}” == “su” ]; # added 20141113
+ then
+ REGISTRAR=`cat ${WHOIS_TMP} | ${AWK} -F: ‘/registrar:/ && $2 != “” { REGISTRAR=substr($2,6,17) } END { print REGISTRAR }’`
fi
# If the Registrar is NULL, then we didn’t get any data
@@ -302,8 +325,8 @@
if [ “${TLDTYPE}” == “in” -o “${TLDTYPE}” == “info” -o “${TLDTYPE}” == “org” ];
then
tdomdate=`cat ${WHOIS_TMP} | ${AWK} ‘/Expiry Date:/ { print $4 }’`
– tyear=`echo ${tdomdate} | cut -d’-‘ -f1`
– tmon=`echo ${tdomdate} | cut -d’-‘ -f2`
+ tyear=`echo ${tdomdate} | ${CUT} -d’-‘ -f1`
+ tmon=`echo ${tdomdate} | ${CUT} -d’-‘ -f2`
case ${tmon} in
1|01) tmonth=jan ;;
2|02) tmonth=feb ;;
@@ -314,12 +337,12 @@
7|07) tmonth=jul ;;
8|08) tmonth=aug ;;
9|09) tmonth=sep ;;
– 10)tmonth=oct ;;
+ 10) tmonth=oct ;;
11) tmonth=nov ;;
12) tmonth=dec ;;
*) tmonth=0 ;;
esac
– tday=`echo ${tdomdate} | cut -d’-‘ -f3 |cut -d’T’ -f1`
+ tday=`echo ${tdomdate} | ${CUT} -d’-‘ -f3 |${CUT} -d’T’ -f1`
DOMAINDATE=`echo $tday-$tmonth-$tyear`
elif [ “${TLDTYPE}” == “biz” ]; # for .biz domain
then
@@ -330,8 +353,8 @@
elif [ “${TLDTYPE}” == “jp” ]; # for .jp 2010/04/30
then
tdomdate=`cat ${WHOIS_TMP} | awk ‘/Expires on/ { print $3 }’`
– tyear=`echo ${tdomdate} | cut -d’/’ -f1`
– tmon=`echo ${tdomdate} | cut -d’/’ -f2`
+ tyear=`echo ${tdomdate} | ${CUT} -d’/’ -f1`
+ tmon=`echo ${tdomdate} | ${CUT} -d’/’ -f2`
case ${tmon} in
1|01) tmonth=jan ;;
2|02) tmonth=feb ;;
@@ -342,18 +365,18 @@
7|07) tmonth=jul ;;
8|08) tmonth=aug ;;
9|09) tmonth=sep ;;
– 10)tmonth=oct ;;
+ 10) tmonth=oct ;;
11) tmonth=nov ;;
12) tmonth=dec ;;
*) tmonth=0 ;;
esac
– tday=`echo ${tdomdate} | cut -d’/’ -f3`
+ tday=`echo ${tdomdate} | ${CUT} -d’/’ -f3`
DOMAINDATE=`echo $tday-$tmonth-$tyear`
elif [ “${TLDTYPE}” == “ca” ]; # for .ca 2010/04/30
then
tdomdate=`cat ${WHOIS_TMP} | awk ‘/Expiry date/ { print $3 }’`
– tyear=`echo ${tdomdate} | cut -d’/’ -f1`
– tmon=`echo ${tdomdate} | cut -d’/’ -f2`
+ tyear=`echo ${tdomdate} | ${CUT} -d’/’ -f1`
+ tmon=`echo ${tdomdate} | ${CUT} -d’/’ -f2`
case ${tmon} in
1|01) tmonth=jan ;;
2|02) tmonth=feb ;;
@@ -364,13 +387,51 @@
7|07) tmonth=jul ;;
8|08) tmonth=aug ;;
9|09) tmonth=sep ;;
– 10)tmonth=oct ;;
+ 10) tmonth=oct ;;
11) tmonth=nov ;;
12) tmonth=dec ;;
*) tmonth=0 ;;
esac
– tday=`echo ${tdomdate} | cut -d’/’ -f3`
+ tday=`echo ${tdomdate} | ${CUT} -d’/’ -f3`
DOMAINDATE=`echo $tday-$tmonth-$tyear`
+ elif [ “${TLDTYPE}” == “mobi” ]; # for .mobi 2014/08/11
+ then
+ tdomdate=`cat ${WHOIS_TMP} | ${AWK} ‘/Expiration Date:/ { print $2 }’ | ${CUT} -d ‘:’ -f2`
+ tyear=`echo ${tdomdate} | ${CUT} -d’-‘ -f3`
+ tmon=`echo ${tdomdate} |${CUT} -d’-‘ -f2`
+ tmonth=`tolower ${tmon}`
+ tday=`echo ${tdomdate} | ${CUT} -d’-‘ -f1`
+ DOMAINDATE=`echo “${tday}-${tmonth}-${tyear}”`
+ elif [ “${TLDTYPE}” == “us” ]; # for .us 2014/08/11
+ then
+ tdomdate=`cat ${WHOIS_TMP} | ${AWK} ‘/Expiration Date:/’ |${CUT} -d ‘ ‘ -f26-`
+ tyear=`echo ${tdomdate} | ${CUT} -d’ ‘ -f5`
+ tmon=`echo ${tdomdate} |${CUT} -d’ ‘ -f1`
+ tmonth=`tolower ${tmon}`
+ tday=`echo ${tdomdate} | ${CUT} -d’ ‘ -f2`
+ DOMAINDATE=`echo “${tday}-${tmonth}-${tyear}”`
+ elif [ “${TLDTYPE}” == “ru” -o “${TLDTYPE}” == “su” ]; # for .ru and .su 2014/11/13
+ then
+ tdomdate=`cat ${WHOIS_TMP} | ${AWK} ‘/paid-till:/ { print $2 }’`
+ tyear=`echo ${tdomdate} | ${CUT} -d’.’ -f1`
+ tmon=`echo ${tdomdate} |${CUT} -d’.’ -f2`
+ case ${tmon} in
+ 1|01) tmonth=jan ;;
+ 2|02) tmonth=feb ;;
+ 3|03) tmonth=mar ;;
+ 4|04) tmonth=apr ;;
+ 5|05) tmonth=may ;;
+ 6|06) tmonth=jun ;;
+ 7|07) tmonth=jul ;;
+ 8|08) tmonth=aug ;;
+ 9|09) tmonth=sep ;;
+ 10) tmonth=oct ;;
+ 11) tmonth=nov ;;
+ 12) tmonth=dec ;;
+ *) tmonth=0 ;;
+ esac
+ tday=`echo ${tdomdate} | ${CUT} -d’.’ -f3`
+ DOMAINDATE=`echo “${tday}-${tmonth}-${tyear}”`
else # .com, .edu, .net and may work with others
DOMAINDATE=`cat ${WHOIS_TMP} | ${AWK} ‘/Expiration/ { print $NF }’`
fi
@@ -534,4 +595,3 @@
### Exit with a success indicator
exit 0
–
Jim, is there any possibilities to add Russian(.ru, .su and etc.) domains?
Hello, everyone. I added checks for the .mobi and .us domains on top of the existing version 2 script, and named the new on version 2.1.
To the people having problems running the script, there’s a variable for the program ‘cut’, but the variable was rarely called, usually when cut was called, it was just called as ‘cut’ itself, which doesn’t do you any favors if your cut program isn’t in a place the shell running this script has access to. I changed all calls to ‘cut’ to now call the variable ‘${CUT}’, and also created a variable for the program ‘tr’, which is necessary for the script to function. The new variable is ‘${TR}’, and can be adjusted as needed.
Zoran, I saw your comment and checked the whois info for both yahoo.fr and google.fr – it seems the whois server for the .fr domains doesn’t print expiration data. I’d expect there is a workaround for that, but as I have no .fr domains to check I wasn’t willing to dig any deeper to find it.
Here’s the patch to update domain-check-2.sh to version 2.1.
[code]
— domain-check-2.sh 2014-08-11 13:54:31.262621485 -0400
+++ domain-check-2.1.sh 2014-08-11 16:24:33.016407933 -0400
@@ -4,9 +4,14 @@
#
# Author: Matty
#
-# Current Version: 2.0
+# Current Version: 2.1
#
# Revision History:
+# Version 2.1
+# Bug fix for .mobi and .us — Jim McNamara
+# Added a variable for the location of tr, and made all calls to cut and tr use the variable
+# instead of the command without path
+#
# Version 2.0
# Bug fix for .org, .biz, info, and .ca — Cameron and Jim
#
@@ -127,7 +132,9 @@
WHOIS=”/usr/bin/whois”
DATE=”/bin/date”
CUT=”/usr/bin/cut”
+TR=”/usr/bin/tr”
MAIL=”/bin/mail”
+
# Place to stash temporary files
WHOIS_TMP=”/var/tmp/whois.$$”
@@ -210,7 +217,7 @@
##################################################################
tolower()
{
– LOWER=`echo ${1} | tr [A-Z] [a-z]`
+ LOWER=`echo ${1} | ${TR} [A-Z] [a-z]`
echo $LOWER
}
@@ -226,10 +233,10 @@
sleep 3
# Save the domain since set will trip up the ordering
DOMAIN=${1}
– TLDTYPE=”`echo ${DOMAIN} | cut -d ‘.’ -f3 | tr ‘[A-Z]’ ‘[a-z]’`”
+ TLDTYPE=”`echo ${DOMAIN} | ${CUT} -d ‘.’ -f3 | ${TR} ‘[A-Z]’ ‘[a-z]’`”
if [ “${TLDTYPE}” == “” ];
then
– TLDTYPE=”`echo ${DOMAIN} | cut -d ‘.’ -f2 | tr ‘[A-Z]’ ‘[a-z]’`”
+ TLDTYPE=”`echo ${DOMAIN} | ${CUT} -d ‘.’ -f2 | ${TR} ‘[A-Z]’ ‘[a-z]’`”
fi
# Invoke whois to find the domain registrar and expiration date
@@ -287,6 +294,12 @@
elif [ “${TLDTYPE}” == “ca” ];
then
REGISTRAR=`cat ${WHOIS_TMP} | ${AWK} -F: ‘/Registrar:/ && $0 != “” { getline; REGISTRAR=substr($0,24,17) } END { print REGISTRAR }’`
+ elif [ “${TLDTYPE}” == “mobi” ];
+ then
+ REGISTRAR=`cat ${WHOIS_TMP} | ${AWK} -F : ‘/Updated by Registrar:/ && $2 != “” { REGISTRAR=substr($2,1,17) } END { print REGISTRAR }’`
+ elif [ “${TLDTYPE}” == “us” ];
+ then
+ REGISTRAR=`cat ${WHOIS_TMP} | ${AWK} -F : ‘/Updated by Registrar:/ && $2 != “” { REGISTRAR=substr($2,20,17) } END { print REGISTRAR }’`
fi
# If the Registrar is NULL, then we didn’t get any data
@@ -302,8 +315,8 @@
if [ “${TLDTYPE}” == “in” -o “${TLDTYPE}” == “info” -o “${TLDTYPE}” == “org” ];
then
tdomdate=`cat ${WHOIS_TMP} | ${AWK} ‘/Expiry Date:/ { print $4 }’`
– tyear=`echo ${tdomdate} | cut -d’-‘ -f1`
– tmon=`echo ${tdomdate} | cut -d’-‘ -f2`
+ tyear=`echo ${tdomdate} | ${CUT} -d’-‘ -f1`
+ tmon=`echo ${tdomdate} | ${CUT} -d’-‘ -f2`
case ${tmon} in
1|01) tmonth=jan ;;
2|02) tmonth=feb ;;
@@ -319,7 +332,7 @@
12) tmonth=dec ;;
*) tmonth=0 ;;
esac
– tday=`echo ${tdomdate} | cut -d’-‘ -f3 |cut -d’T’ -f1`
+ tday=`echo ${tdomdate} | ${CUT} -d’-‘ -f3 |${CUT} -d’T’ -f1`
DOMAINDATE=`echo $tday-$tmonth-$tyear`
elif [ “${TLDTYPE}” == “biz” ]; # for .biz domain
then
@@ -330,8 +343,8 @@
elif [ “${TLDTYPE}” == “jp” ]; # for .jp 2010/04/30
then
tdomdate=`cat ${WHOIS_TMP} | awk ‘/Expires on/ { print $3 }’`
– tyear=`echo ${tdomdate} | cut -d’/’ -f1`
– tmon=`echo ${tdomdate} | cut -d’/’ -f2`
+ tyear=`echo ${tdomdate} | ${CUT} -d’/’ -f1`
+ tmon=`echo ${tdomdate} | ${CUT} -d’/’ -f2`
case ${tmon} in
1|01) tmonth=jan ;;
2|02) tmonth=feb ;;
@@ -347,13 +360,13 @@
12) tmonth=dec ;;
*) tmonth=0 ;;
esac
– tday=`echo ${tdomdate} | cut -d’/’ -f3`
+ tday=`echo ${tdomdate} | ${CUT} -d’/’ -f3`
DOMAINDATE=`echo $tday-$tmonth-$tyear`
elif [ “${TLDTYPE}” == “ca” ]; # for .ca 2010/04/30
then
tdomdate=`cat ${WHOIS_TMP} | awk ‘/Expiry date/ { print $3 }’`
– tyear=`echo ${tdomdate} | cut -d’/’ -f1`
– tmon=`echo ${tdomdate} | cut -d’/’ -f2`
+ tyear=`echo ${tdomdate} | ${CUT} -d’/’ -f1`
+ tmon=`echo ${tdomdate} | ${CUT} -d’/’ -f2`
case ${tmon} in
1|01) tmonth=jan ;;
2|02) tmonth=feb ;;
@@ -369,8 +382,24 @@
12) tmonth=dec ;;
*) tmonth=0 ;;
esac
– tday=`echo ${tdomdate} | cut -d’/’ -f3`
+ tday=`echo ${tdomdate} | ${CUT} -d’/’ -f3`
DOMAINDATE=`echo $tday-$tmonth-$tyear`
+ elif [ “${TLDTYPE}” == “mobi” ]; # for .mobi 2014/08/11
+ then
+ tdomdate=`cat ${WHOIS_TMP} | ${AWK} ‘/Expiration Date:/ { print $2 }’ | ${CUT} -d ‘:’ -f2`
+ tyear=`echo ${tdomdate} | ${CUT} -d’-‘ -f3`
+ tmon=`echo ${tdomdate} |${CUT} -d’-‘ -f2`
+ tmonth=`tolower ${tmon}`
+ tday=`echo ${tdomdate} | ${CUT} -d’-‘ -f1`
+ DOMAINDATE=`echo “${tday}-${tmonth}-${tyear}”`
+ elif [ “${TLDTYPE}” == “us” ]; # for .us 2014/08/11
+ then
+ tdomdate=`cat ${WHOIS_TMP} | ${AWK} ‘/Expiration Date:/’ |${CUT} -d ‘ ‘ -f26-`
+ tyear=`echo ${tdomdate} | ${CUT} -d’ ‘ -f5`
+ tmon=`echo ${tdomdate} |${CUT} -d’ ‘ -f1`
+ tmonth=`tolower ${tmon}`
+ tday=`echo ${tdomdate} | ${CUT} -d’ ‘ -f2`
+ DOMAINDATE=`echo “${tday}-${tmonth}-${tyear}”`
else # .com, .edu, .net and may work with others
DOMAINDATE=`cat ${WHOIS_TMP} | ${AWK} ‘/Expiration/ { print $NF }’`
fi
[/code]
hello,
realy great work!
do you have any update for .fr? i have around 300 domain to test so if you can help it will be great.
Thx
Here’s a patch that includes Jim’s fixes above (.org, .info, .biz), along with support for .ca domains:
Thanks! I have uploaded patched version:
And here’s another, for .biz. All the math worked on this one, but the spacing of the whois output was leaving the registrar blank.
This patch assumes a default domain-check-2.txt version 1.9, and patches the .org, .info, and .biz issues I’ve encountered.
I also noticed .org and .info domains were no longer working. The whois servers added an ID number that was showing up as the registrar, and changed the date format. This patch works to repair version 1.9 of check-domain-2.txt for .org and .info files.
.org domains no longer work for me is anyone else having this issue?
Thanks! That is a handy little script.
getting unknown for .me domains.
Has anyone got this to work with .ca domains? I have tried adding the snippet above, but it doesn’t seem to work.
Thanks!
How can I optimize the code to make it work for .CH domains?
Regards
actually co.uk domains dosent wokr here also.
Does anyone knows how to fix the bug ?
hello guy, great script!
I also would like to understand how to extend the script with domain “.it” and how to integrate it with nagios. Please can you contact me via email?
tks!
When the whois server does not return Expiration Date at all (as for certain .ro domains with “eternal” registration), the script still returns “Expired”, not “Unknown” as it would be expected.
does anyone has experience how to add italian domains check to the script
i did like this:
then
${WHOIS} -h “whois.nic.it” “${1}” > ${WHOIS_TMP}
elif [ “${TLDTYPE}” == “it” ]; # italy
but its wasnt work.
@r.s, have you solved for .it domain ?
i’ve a little budget, can someone help me?
tks
hi i didint sloved yet. Still waiting information.
@1tizio i sloved it domains issue. If u can help me with co.uk domains issue i can help u 🙂
Please provide me availability of this domin and if not then provide me expairy date of this domin.
Thanking you.
Shree Krishna
@yann,
Can you post your ‘.fr’ update ?
Thanks
Thank you for this script !
it is well written, easy to update…
i have added the “.fr” domains management for the french people (if you need i will send to you)
Hi Yann,
can you send me your update please ?
Thank you
Vincent
yann, i’m very interested for this upgrade could you sent me your addition or the complete script ?
Thx
I am trying to find expiry of .ca domains. I added the code mentioned by AJ above. Does not seem to be working. Has any one figured out how to get expiry for .ca domains.
Thanks
I just get UNKNOWN. What am I doing wrong. Here is my command line:
domain-check-2.sh -a -f /home/sniadmin/Domain-List -x 30 -e mail@domain.com > /home/sniadmin/LOGS/domain-log.txt
This dont works with Brazilian Registrar
whois.registro.br
tld: .com.br
Can you improve with this? Thanks friend.
Can this script work on FreeBSD server?
Can you give me more explain how to work with this script? What to do with domain-check-2.txt, where i need to put this file?
Hi,
I would appreciate if you could add support for .nl domains.
In fact, wouldn’t it be easier to add a configuration file with country specific code so the script itself wouldn’t be so bulky? Or at least, put the code for each country together. That would make it a whole lot shorter without all the repeated ifs / elifs., just my two cents…
I can simply add the section to add the dutch whois server, but the regular expression to make sense of the output is beyond me (i’m no scripting guru you know). I suppose this something like the next part would work
elif [ “${TLDTYPE}” == “nl” ]; # Netherlands
then
${WHOIS} -h “whois.domain-registry.nl” “${1}” > ${WHOIS_TMP}
one problem is that the dutch whois won’t accept many request per IP so some error-handling would be needed…
Thanks for providing a useful script!
I was getting the following error while checking .uk domains:
Fixed it by adding the following line after the WHOIS command is run:
Does it work for .de domains?
why there is error in freebsd?
./domain-check -d vivekgite.com
Domain Registrar Status Expires Days Left
———————————– —————– ——– ———– ———
[: unexpected operator
[: unexpected operator
[: unexpected operator
[: unexpected operator
[: unexpected operator
[: unexpected operator
[: unexpected operator
[: unexpected operator
[: unexpected operator
[: unexpected operator
[: unexpected operator
[: unexpected operator
[: unexpected operator
[: unexpected operator
vivekgite.com GODADDY.COM, INC. Valid 18-aug-2014 1140
hy there the new whois servers are whit CAPCHA any change to pass them?
Hello,
Can you please tell me what to do if I want to know *any* names from .IN domain expiration ? is there a way to do that ?
Example: I don’t want to search for the name and put in the .txt file .. I want it do automatic list out any expiration domain from .IN .
To add .ca domains:
Edited by admin to add pre tags.
I tried adding the support for .ca domains but now I am getting all .ca domains being expired. Here is an example
domain.ca Go Daddy Domains Expired -0- -2455855
Cira has made some changes to their DNS records. Anyone wanting to check .ca domains will need to make the following changes.
form:
tdomdate=`cat ${WHOIS_TMP} | awk ‘/Renewal date/ { print $3 }’`
to:
tdomdate=`cat ${WHOIS_TMP} | awk ‘/Expiry date/ { print $3 }’`
Very Nice Script,
i will try it with .de domains.
Thanks for good tutorial.
Hello, when i am use the code for a file then i get this message:
whois: bizr.whois-servers.net: nodename nor servname provided, or not known
I am use a mac for this script, maybe you can help me 🙂
Merry Christmas 🙂
As always you wrote a very good tutorial. Thanks for this great script, it makes my life lot easier! GBU Vivek!
Hello ZlayaZhaba,
you are correct there is no expiration date, the registration in the Netherland is normaly one year. That would be Record last updatedpdated + 1 Year = expiration date.
Can you help me ?
Rik
to: Rik D
I would like to check .NL domains ( Netherlands ) I tried to change Whois server into “whois.domain-registry.nl†but i get on every output “Unknown 
Very funny zone!
As i see in answer of whois it has only two fields:
– Date registered:
– Record last updated:
And nothing like expiration date! Probably it must be calculated manually on base of last update?
Hello,
I would like to check .NL domains ( Netherlands ) I tried to change Whois server into “whois.domain-registry.nl” but i get on every output “Unknown”
Who can help me ?
Thanks in advance
Rik
Nice modification of original script, man, thanks.
But looks like you forgot about variable MAIL 😉
Thanks for the heads up!
For some reason this script will only output “UNKNOWN” to all fields when using a large list/batch mode. It seems that any more than 5 domains in a list cause this (at least for me). Any thoughts as to why this might be?
never mind i glanced over it:
“whois.pir.org”
“whois.registry.in”
“whois.nic.uk”
“whois.neulevel.biz”
“whois.afilias.info”
“whois.jprs.jp”
You can use -s option to set another whois server
/script.name -d example.com -s whois.isp.com
Looks nice.
Do you have to modify what register the script checks?
I could not tell where the script is requesting the data from, can you please clarify?
Thanks,
Cypher
Just repeating GM’s question.. sending email but getting error msgs “/bin/sh: /home/xcyte/file.sh/domain-check-2: No such file or directory” even though I’ve followed the instructions exactly. Anyone more experienced that wants some cash to help me get this running email me at jgrimmond00@gmail.com.. thanks
Brilliant script, thanks.
Could anyone post their nagios version if they have it please. Many thanks!
Neil,
Okai, I’ve updated the script to support .uk 2nd level TLD. Try it out and let me know…
Hi again.
Next question. 🙂 I am trying to mod it to look up .uk domains.
The whois server is whois.nic.uk and the date is output as Renewal date: dd-Mmm-YYYY
Unfortunately I am not up to speed with awk and have probably made a couple of other errors too.
Are you able to assist please?
Many thanks in advance,
Neil.
Hi Vivek.
I just wanted to say thank you for providing this script.
It is an absolutely excellent time-saver for me and a great learning tool too!
All the best,
Neil.
Great script, but it sends no email? what i`m doing wrong?
Its an awesome tool. I just checked one domain. yet to check using file. but so far it impressed me.
thanks.
Very nice script. Is there already an extension to do “nameserver lookups”, means looking for each domain, what nameservers are registered? would be really nice since not all are so helpful and tell us that the domain is no longer on our nameserver…
Very nice script – please give me a link or email address to obtain the nagios version of it
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
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!
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.
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.
# 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
dave,
I’m not sure if mark can get your message.
Mark: Would love to grab a copy of your Nagios version of script! Can you post a link or something? Thanks a bundle.
Its great script. does any one know similar php script?
are there any additions to the script that I can put in so it e-mails out when it finds an “unknown” domain?
what I mean by skipped, is that is says unknown, but when I look it up manualy it showes that the domain is valid
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
kendall,
Did you renamed the script? Did you setup executable permission? Did you run script as:
I can’t get the script to work for me. I get the following error:
-bash: domain-check: command not found
This script works much better than some of the others on the net. Thanks!
Sure post the script / url / link. If you don’t have a website just email me the script 🙂
I’ve hacked the script to work somewhat with Nagios.
Does anyone want it?
realy good works thanks a lot vivek
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
but… it doesnt work with things like .co.nz domains…