?
Solved

multiple whois queries

Posted on 2003-03-17
7
Medium Priority
?
186 Views
Last Modified: 2010-05-18
I would like to build a program which will be able to ask internic for a whois then ask the autoritive registrar's whois server for information and loop it 50 times (max).  I have been using a command line program which works very well except for the occasional "Can't print to server" error.  I hve three questions:
1.  Is there a way to keep a channel open for multiple queries?
2.  How does one keep the program working after such an error?
3.  Using the following script how does one change the whois server dynamically?

my $out=whois($host);

print $out;

sub whois {
   my $sock = IO::Socket::INET->new(
   PeerAddr => ($_[1]?$_[1]:'whois.publicinterestregistry.net'),
   PeerPort => 'whois(43)',
   Proto    => 'tcp',
   Timeout  => 60) or die "IO::Socket::INET: $!";

   $sock->print($_[0],"\r\n");
   my @result=$sock->getlines;
   $sock->close;
   return wantarray?@result:join('',@result);
}

Thanks for your help.
0
Comment
Question by:blenkhn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 48

Expert Comment

by:Tintin
ID: 8158161
0
 
LVL 1

Expert Comment

by:Trevize
ID: 8162972
1. No, the WHOIS protocol doesn't have this possibility.

2. Automatic retry:

my $out;
for (1..10)
{
   eval
   {
      $out = whois($host);
   };

   last unless $@;  # stop trying if successful

   sleep(1);        # wait 1 seconds before next try
}

if (defined $out)
{
   print $out;
}
else
{
   print STDERR "Could not retrieve domain information";
}

3. Do you mean this:

out = whois($host, "whois.something.net");
0
 

Author Comment

by:blenkhn
ID: 8167164
Thanks for your reply,

With using the statement

out = whois($host, "whois.something.net");

do I still need to have the statement

 PeerAddr => ($_[1]?$_[1]:'whois.publicinterestregistry.net').

How do I change the script to do this?

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Expert Comment

by:Trevize
ID: 8168836
You don't need to change anything - either you set the whois server explicitly when calling the whois() function or it uses the default server (whois.publicinterestregistry.net).
0
 

Author Comment

by:blenkhn
ID: 8171182
Thanks for your reply,

With using the statement

out = whois($host, "whois.something.net");

do I still need to have the statement

 PeerAddr => ($_[1]?$_[1]:'whois.publicinterestregistry.net').

How do I change the script to do this?

0
 
LVL 1

Accepted Solution

by:
Trevize earned 375 total points
ID: 8173816
You don't need to change anything - either you set the whois server explicitly when calling the whois() function or it uses the default server (whois.publicinterestregistry.net).
0
 

Author Comment

by:blenkhn
ID: 8281390
I have used your suggestion to cancel out the errors occuring from the whois server.  what about transmission errors?  maybe a timer to rehit the server after so long? How would one check to see if the complete record has been received?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question