By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,176 Members | 984 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,176 IT Pros & Developers. It's quick & easy.

gethostbyaddr

P: 23
I'm writing a script that takes a list of ipaddresses as input and converts them to hostnames.......

The problem here is some of the ip addresses do not resolve to their hostnames and for those ip addresses perl get hung and never goes to resolve the next given ipaddress....

Any suggestion is appreciated !
Expand|Select|Wrap|Line Numbers
  1. open (F,$filename) or die 'Cannot open file';
  2. while(<F>){
  3. push @sip,$_;
  4. }
  5. foreach $sip(@sip){
  6. chomp($sip);
  7. $packaddr = pack ("C4", split (/\./, $sip) );
  8. $ns = gethostbyaddr($packaddr, 2);
  9. print "$sip ------- $ns\n";
  10. close F;
  11.  
Jun 19 '08 #1
Share this Question
Share on Google+
1 Reply


P: 23
I used the http://search.cpan.org/~patl/Time-Out-0.10/Out.pod, it works well with Linux systems, but doesn't work on windows, any help appreciated,
Expand|Select|Wrap|Line Numbers
  1. foreach $sip(@sip){
  2. $bcd = timeout $nb_sec => sub{
  3. chomp($sip);
  4. $packaddr = pack ("C4", split (/\./, $sip) );
  5. $ns = gethostbyaddr($packaddr, 2);
  6. print "$sip ------- $ns\n";
  7. }
  8. };
  9.  
Jun 19 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.