gethostbyaddr

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • karthikeyanck
    New Member
    • Oct 2007
    • 23

    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 !
    Code:
    open (F,$filename) or die 'Cannot open file';
    while(<F>){
    push @sip,$_;
    }
    foreach $sip(@sip){
    chomp($sip);
    $packaddr = pack ("C4", split (/\./, $sip) );
    $ns = gethostbyaddr($packaddr, 2);
    print "$sip ------- $ns\n";
    close F;
    Last edited by eWish; Jun 21 '08, 04:01 AM. Reason: Removed [B][/B] Tags
  • karthikeyanck
    New Member
    • Oct 2007
    • 23

    #2
    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,
    Code:
    foreach $sip(@sip){
    $bcd = timeout $nb_sec => sub{
    chomp($sip);
    $packaddr = pack ("C4", split (/\./, $sip) );
    $ns = gethostbyaddr($packaddr, 2);
    print "$sip ------- $ns\n";
    }
    };
    Last edited by eWish; Jun 21 '08, 04:01 AM. Reason: Removed [B][/B] Tags

    Comment

    Working...