in reply to Re: resolving ip's to names in a text file
in thread resolving ip's to names in a text file

I am not sure if Net::Whois is really what fits the case if he just wants to resolve an ip address to a dns entry. I think that Net::DNS::RR::PTR is more suitable.

humbly -c

  • Comment on Re: Re: resolving ip's to names in a text file

Replies are listed 'Best First'.
Re: Re: Re: resolving ip's to names in a text file
by softworkz (Monk) on Jul 20, 2001 at 16:36 UTC
    I'm not sure of your input file but this should get you started in the right direction, if not maybe someone can learn a tip of two. HAVE FUN!
    #!/usr/bin/perl-w use strict; use win32; my $in_name=$ARGV[0]; my $out_name=$ARGV[1]; our (@x); # new type of global declaraton # carefull commas needed I.E. our (@x, @y); # use vars qw ( @x @y ); <- obsolete global declaration # pass a reminder if($#ARGV < 1) { die "usage: ip.pl <input file> <output file>\n" . "for example: program.pl infile.txt outfile.txt\n" } open(FILE, $in_name) || die "ip.pl can't open $in_name: $!"; open(IPFILE,">$out_name") || die "ip.pl can't open $out_name: $!"; my $dns2="toto"; #157.173.20.2 my $dns3="oz"; #157.173.20.3 my $dns4="wizard"; #157.173.20.4 my $ip2; my $ip3; my $ip4; while (<FILE>){ # sample line # Tz25,D,wizard,2,157.173.20.2,Local @x=split(/,/); next unless (($_ =~ /Local/)||($_ =~ /Network/)); if ($x[4] =~ /157.173.20.2/){ $ip2 = $dns2; print $x[0], $x[1], $x[2], $ip2; print IPFILE; } }
Re: Re: Re: resolving ip's to names in a text file
by RayRay459 (Pilgrim) on Jul 20, 2001 at 19:47 UTC
    That is exactly right. After doing a lookup on Net::Whois...i saw that that wasn't what i needed. I need to have it lookup the ip addresses in our local dns server. Thank you. ~Ray~