| Category: | Networking |
| Author/Contact Info | perldork |
| Description: | Pass this script a list of space separated IP addresses and/or host names and it will return back a list with the primary IP for hostnames and the primary canonical name for IP addresses. |
for (@ARGV){$l=length()+1if(length($_)>$l);}
for (sort @ARGV) {
printf
qq#%-${l}s %s\n#,"$_:",
qq-@{[/^\D/o?join '.',unpack('C4',gethostbyname $_)
:scalar gethostbyaddr(pack('C4',split '\.'),2)]}-;
}
|
|
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Simple nslookup with perl
by data64 (Chaplain) on Mar 07, 2002 at 04:10 UTC |