Here's a quick and nasty hack/script to detect IPs in STDIN and find their reverse DNS. Yes, reverse DNS can be done in a far nicer way, but this was quicker/shorter. Complete with echo off.
This is handy for finding reverse DNS for a heap of IPs, like those for my webhost that no longer does reverse DNS for web-stats.
Win.
#!/usr/bin/perl -w
#Code by Rhett Kipps - www.kipps.com.au
use strict;
my $stty_orig = `stty -g`;
`stty -echo`;
my $hostname;
while (<STDIN>) {
if (/([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})/) {
$hostname = `host $1`;
$hostname =~ s/.+?domain name pointer //;
print $hostname;
}
}
`stty $stty_orig`;