467,081 Members | 1,135 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,081 developers. It's quick & easy.

gethostbyaddr

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
  • viewed: 2784
Share:
1 Reply
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.

Similar topics

1 post views Thread by O.B. | last post: by
reply views Thread by Sibylle Koczian | last post: by
2 posts views Thread by Neil Aggarwal | last post: by
1 post views Thread by kcw3388@hotmail.com | last post: by
2 posts views Thread by Harlin Seritt | last post: by
reply views Thread by Jørn Dahl-Stamnes | last post: by
2 posts views Thread by christian9997@hotmail.com | last post: by
24 posts views Thread by RJ_32 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.