Skip to page content or Skip to Accesskey List.


Main Page Content

Perl Shell Program For Whois

Rated 4.08 (Ratings: 1)

Want more?

  • More articles in Code
Picture of AnthonyB

Anthony Baratta

Member info

User since: 10 Jul 1999

Articles written: 12

Necessity maybe the mother of invention, but some times little 'side' projects can keep you from going crazy under tight deadlines. I've been beating my body silly the last two weeks to put together a e-commerce solution for one of my clients. Today was 'very' mentally draining with the 'final-final' review, edits, tweaks and 'oh-my-gawd-we-forgot-to...' going on.

During this 'hectic' time, I forced myself a few minutes here and there to divert my brain from the stress and wrote the following script. Believe it or not, the exercise really helped me stay focused on the important work.

Anyhoo - to make a long story longer, I was a little pissed off about the changes to and the new 'limited' whois results. So I wrote the following Perl script to query using the standard *NIX whois executable, capture the info - and if the domain existed, snag the whois server name from the info presented and offer you the option to query the responsible registrar for more detail on the domain.

I think its pretty slick. There might be a better way to do some of the things in the script, but output was more important than code elegance. Enjoy. Feedback is appreciated. Cut out the code between the demarcations below and watch out for line wrap. Save to a text file called 'ewhois' and place in your /home/username/bin directory. chmod to 755. To use, type 'ewhois domain.tld'. Note: I've found that there are some very handy extensions to the new internic whois (not mine). You can enter no extension (e.g. 'whois domain') and it will search all of the .com, .edu, .org and .net extensions for you - giving you a hit list of 'registered' domains. Also if you include no extension, but just the trailing '.' (e.g. 'whois domain.') it give you a hit list of all domains that _begin_ with the word entered.



## eWhois, an extended Whois Program


## Version .9b

## CopyLeft KeyBoard Jockeys, 1999



## This program is NOT web browser safe!!

## There is no checking for 'funny' stuff.

## Do not use via a browser on an unsecure page.

## Just give the address you want

## to ewhois and if it exists in

## the database,

## you'll be given the option to

## extend the search to the regitry

## who holds the source of the whois info

## edit the $varWhoisExe for your server

## put in your /home/username/bin directory

## chmod to 755

## usage: ewhois

## ewhois foo.

## ewhois foo

## Edit this variable for your whois program

## Note some linux versions alias whois for fwhois

$varWhoisExe = "/usr/bin/fwhois";

# $varWhoisExe = "/usr/bin/whois";

## Setting target of whois

$varWhoisTarget = lc($ARGV[0]);

## If no arguments passed to program show help

if ($varWhoisTarget) {

print "Processing...


$varWhoisExe .= " " . $varWhoisTarget;

$varWhoisResultOne = `$varWhoisExe`;

print $varWhoisResultOne;

$varIndex = index(lc($varWhoisResultOne),"whois server:");

if ($varIndex > -1) {

$varIndex1 = index(lc($varWhoisResultOne),"whois\.");

$varIndex2 = index(lc($varWhoisResultOne),"\.",($varIndex1+7));

$varLength = ($varIndex2 + 4) - $varIndex1;

$varWhoisServer = substr($varWhoisResultOne,$varIndex1,$varLength);

$varWhoisExe .= "\@" . $varWhoisServer;

print "Query " . $varWhoisServer . " for more info on " . $varWhoisTarget . "? (y\/n) ";


if (lc($varAnswer) eq "y") {

print "



$varWhoisResultTwo = `$varWhoisExe`;

print $varWhoisResultTwo;



} else {

print "

usage: ewhois domain.tld

ewhois domain.

ewhois domain




Mutated into a life-size Dilbert doll, Anthony spends the days wedged into his replica of Cardinal Fang's Comfy Chair coding solutions to the most thorny of internet software problems.

The access keys for this page are: ALT (Control on a Mac) plus: is an all-volunteer resource for web developers made up of a discussion list, a browser archive, and member-submitted articles. This article is the property of its author, please do not redistribute or use elsewhere without checking with the author.