Nov 2, 2012
kalpesh

Linux: Bash script to get email address and created/updated/expires dates of domain name

In linux, to check the whois of any domain name, the simple command is:

whois domainname.com

But, it will show you so many things which are not important, e.g. it will show you the NOTICE and TERMS of USE and so many other things.

If you are only concerned of getting the email address and creation/updation/expiry date of domain name from whois, here is the bash script that will help you out.
First create a bash script file, e.g. whoisEmailAndDates.sh and give it permissions to run:

touch whoisEmailAndDates.sh
chmod 744 whoisEmailAndDates.sh

Now, copy below code and paste it in the newly created file:

#!/bin/sh

echo ""
echo "######## WHOIS: "$1

# Whois using the input variable
whois $1 |\

# Remove EOL characters
tr -d '\015\032' |\

# Remove leading spaces
sed 's/^ *//' |\

# Remove common unnecessary words from output
grep -v  -e "http://" -e "WHOIS" > wtmp1.txt

# Display all of the date lines and email addresses
grep -Eio '([[:alnum:]_.]+@[[:alnum:]_]+ ?\.[[:alpha:].]{2,6})' wtmp1.txt
egrep -i "ate: " wtmp1.txt 

# Remove the tmp file
rm -rf wtmp1.txt

echo "######## DONE!"
echo ""

Now, run the script for the domain:

./whoisEmailAndDates.sh google.com

You’ll be greeted with following output!

######## WHOIS: google.com
admin@google.com
admin@google.com
admin@google.com
admin@google.com
Updated Date: 20-jul-2011
Creation Date: 15-sep-1997
Expiration Date: 14-sep-2020
######## DONE!

1 Comment

  • Great!
    A lot simple and better than others!
    Thanks a millions!

Leave a comment

 

Welcome to my Blog

Kalpesh MehtaHelping Magento developers in their day-to-day development problems since 2011. Most of the problems and solutions here are my own experiences while working on different projects. Enjoy the blog and don't forget to throw comments and likes/+1's/tweets on posts you like. Thanks for visiting!

Certifications

Honor

Recognition

Magento top 50 contributors

Magento top 50 contributors

Contributions