Dan.com

Simple CLI script to search available names from zone files

Namecheap

paperball

Established Member
Impact
56
Hello fellow domainers,

I wrote a very basic Command Line script that can be used offline. It works on Windows OS(with Cygwin) too. It checks the registration status of .com domain names from a .com Zone file(can be used with any other TLD with a simple modification).

Firstly we need to parse the DNS zone file("com.zone" in the code). For this I have taken a reference from Matt Mazur's blog for the first 3 steps:

Code:
$ awk '{print $1}' com.zone > domains-only.txt


Code:
$ sort -u domains-only.txt --output domains-unique.txt


Code:
$ LC_ALL=C grep '^[A-Z0-9\-]*$' domains-unique.txt > domains.txt


Step no. 3 might not work if you're on Cygwin. You can leave this step in this case.

(Optional Step) To remove the dots at the end of domains when step 3 fails.

Code:
sed -r 's/.{1}$//' domains.txt > domains-final.txt

After this, create a bash script on your computer. For doing this:

On your linux device's terminal(Cygwin on Windows), write this code to create a bash script ("dnc" in this case):

Code:
touch dnc

Then, open the file with a text editor. On Windows, you can use NotePad++ to do this and you need to set Edit>EOL Conversion>Unix(LF) option for the bash script.

Paste the code below into the "dnc" script file, save the file and place it in the same directory as domains-final.txt from Step 4.

Code:
#!/bin/bash
while true;
do
  echo "";
  read -p "Enter domain > " dname
 
cmmnd=$(fgrep -w "$dname" domains-final.txt)
if [[ $cmmnd == $dname ]]
then
  echo -e "\033[1A\033[2K$dname \e[97m\e[41mRegistered\033[0m"
else
  echo -e "\033[1A\033[2K$dname \e[97m\e[42mAvailable\033[0m"
fi
done;

Save the open the terminal, navigate to the script's and parsed domain file directory in terminal with CD command, for example:

Code:
cd D:/clitool

Lastly, run the script "dnc" in terminal like:

Code:
./dnc

You can now perform availability checks for .com domains in the terminal. A screenshot of the script in action:

LFiOavo.jpeg


This is a very basic script. It might be slow if your computer has light specifications. However, it helps against logging.
 
Last edited:
Top