Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

UNIX Bash – Domain List Get Whois Info

Posted on August 25, 2016September 2, 2016 By David Kittell

If you manage a list of domains it’s sometimes helpful to have a script like this to check the information from time to time.

I plan to clean this up in time but for now this works.

First create a text file like below that has domains in it

google.com
yahoo.com
microsoft.com

Then create and run this bash/shell script

#!/bin/sh

#  whois-DomainList.sh
#
#
#  Created by David Kittell on 8/25/16.
#

# Variables - Start
dt=$(echo `date +%Y_%m_%d_%H.%M.%S`)
sDatedName="DomainListDetails_$dt.txt"
# Variables - Stop

#echo "Domain Information for $1"
#whois $1 | egrep -i 'Expiration Date:|Expires on|Registrar:|Name Server:'

echo "Running Process..."
rm $sDatedName

cat domainlist.txt  | while read line; do
lLine="$(echo $line | tr '[A-Z]' '[a-z]')"
echo "\n$lLine\n" >> $sDatedName;
echo "\n$lLine"

case "$lLine" in
*".healthcare"*)
#echo domain is .healthcare
host=whois.donuts.co
#echo $lLine
#echo $host
echo -i "whois -h whois.donuts.co $line | egrep -i 'Registry Expiry Date:|Sponsoring Registrar:|Name Server:'"
whoisinfo=$(whois -h whois.donuts.co $line | egrep -i 'Registry Expiry Date:|Sponsoring Registrar:|Name Server:')
echo $whoisinfo >> $sDatedName
;;
*".is"*)
#echo domain is .is
host=whois.isnic.is
whoisinfo=$(whois -h $host $lLine | egrep -i 'expires:|nserver:|source:|role:')
echo $whoisinfo >> $sDatedName
;;
*".pharmacy"*)
#echo domain is .pharmacy
host=whois.nic.pharmacy
whoisinfo=$(whois -h $host $lLine | egrep -i 'Registry Expiry Date:|Sponsoring Registrar:|Name Server:')
echo $whoisinfo >> $sDatedName
;;
*".cc"*)
#echo domain is .pharmacy
host=whois.nic.cc
whoisinfo=$(whois -h $host $lLine | egrep -i 'Expiration Date:|Expires on|Registrar:|Name Server:')
echo $whoisinfo >> $sDatedName
;;
*".coop"*)
#echo domain is .pharmacy
host=whois.nic.coop
whoisinfo=$(whois -h $host $lLine | egrep -i 'Expiration Date:|Expires on|Registrar:|Name Server:')
echo $whoisinfo >> $sDatedName
;;
*".edu"*)
#echo domain is .pharmacy
host=whois.educause.edu
whoisinfo="Registrar: Educause.edu\n$(whois -h $host $lLine | egrep -i 'Domain expires:' && whois -h $host $lLine | grep -A5 'Name Servers:')"
echo $whoisinfo >> $sDatedName
;;
*".im"*)
#echo domain is .pharmacy
host=whois.nic.im
whoisinfo=$(whois -h $host $lLine | egrep -i 'Expiration Date:|Expires on|Registrar:|Name Server:')
echo $whoisinfo >> $sDatedName
;;
*".pro"*)
#echo domain is .pharmacy
host=whois.RegistryPro.pro
whoisinfo=$(whois -h $host $lLine | egrep -i 'Expiration Date:|Expires on|Registrar:|Name Server:')
echo $whoisinfo >> $sDatedName
;;
*".tv"*)
#echo domain is .pharmacy
host=whois.nic.tv
whoisinfo=$(whois -h $host $lLine | egrep -i 'Expiration Date:|Expires on|Registrar:|Name Server:')
echo $whoisinfo >> $sDatedName
;;
*".us"*)
#echo domain is .pharmacy
host=whois.nic.us
whoisinfo=$(whois -h $host $lLine | egrep -i 'Expiration Date:|Expires on|Registrar:|Name Server:')
echo $whoisinfo >> $sDatedName
;;
*".org"*)
#echo domain is .org
host=whois.pir.org
whoisinfo=$(whois -h $host $lLine | egrep -i 'Registry Expiry Date:|Registrar:|Name Server:')
echo $whoisinfo >> $sDatedName
;;
*".biz"*)
#echo domain is .biz
host=whois.biz
whoisinfo=$(whois -h $host $lLine | egrep -i 'Expiration Date:|Expires on|Sponsoring Registrar:|Name Server:')
echo $whoisinfo >> $sDatedName
;;
*".info"*)
#echo domain is .info
host=whois.afilias.info
whoisinfo=$(whois -h $host $lLine | egrep -i 'Registry Expiry Date:|Sponsoring Registrar:|Name Server:')
echo $whoisinfo >> $sDatedName
;;
*)
#echo unknown
host=whois.crsnic.net
whoisinfo=$(whois -h $host $lLine | egrep -i 'Expiration Date:|Expires on|Registrar:|Name Server:')
echo $whoisinfo >> $sDatedName
;;
esac

echo " -> $host"
echo $whoisinfo


echo "------------------------------------------" >> $sDatedName

done

#echo "\nName Server Information"
#nslookup -query=ns $1 | egrep -i 'nameserver' |  awk '{print $4}' # | cut -d/ -f1
echo "Process complete"
exit
Originally Posted on August 25, 2016
Last Updated on September 2, 2016
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

CentOS Code DNS Fedora Mac OS X Shell Mac OSX Red Hat Ubuntu UNIX UNIX Shell Scripts

Post navigation

Previous post
Next post

Related Posts

Ektron DMS File List

Posted on February 3, 2015October 26, 2015

Following my code on Ektron – DMS Content List I created this Ektron Widget <%@ Control Language="C#" AutoEventWireup="true" CodeFile="DMSFileList.aspx.cs" Inherits="widgets_DMSFileList" Debug="true" %> <asp:MultiView ID="ViewSet" runat="server" ActiveViewIndex="0"> <asp:View ID="View" runat="server"> <asp:Label runat="server" ID="lblDMSList">DMS Files</asp:Label> <asp:ListView ID="lvDMSList" runat="server" ItemPlaceholderID="aspItemPlaceholder" Visible="false"> <EmptyDataTemplate> <asp:Literal ID="litEmptyDataBasic" runat="server" Text="text" OnInit="litEmptyData_Init" /> </EmptyDataTemplate> <LayoutTemplate> <div class="form" style="max-width:…

Read More

Mac OSX – Terminal – Read JSON From cURL

Posted on September 15, 2016September 15, 2016

Prerequisite: OSX Homebrew brew update brew prune brew install node brew upgrade node sudo curl -L https://npmjs.com/install.sh | sh npm update -g npm install -g json brew install python pip install pygments curl -s https://www.kittell.net/tools/jsonexample.php | json | pygmentize -l json curl -s –header "PRIVATE-TOKEN: <private token>" "http://127.0.0.1/api/v3/projects" | json…

Read More

Mac OSX Terminal – Lynx HTML Parsing

Posted on January 1, 2018

Lynx has a lot of good purposes but in this example below I’m simply going to strip URLs from a bookmarks HTML file exported from Chrome. brew install lynx lynx -dump -nonumbers -listonly bookmarks_11_18_16.html > links1.txt If you have created folders and links all over the place in Chrome or…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
©2025 David Kittell | WordPress Theme by SuperbThemes