Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Want to write a script to do the batch conversion from domain name to IP.

Reply
Thread Tools

Want to write a script to do the batch conversion from domain name to IP.

 
 
Hongyi Zhao
Guest
Posts: n/a
 
      02-01-2009
On Sat, 31 Jan 2009 08:53:47 -0800, "John W. Krahn"
<(E-Mail Removed)> wrote:

>#!/usr/bin/perl
>use warnings;
>use strict;
>use Socket;
>
>while ( <> ) {
> chomp;
> my ( $address, $port ) = split /:/ or next;
> my $number = inet_aton $address;
> my $name = gethostbyaddr $number, AF_INET;


Considering that NOT ALL IPs can be resolved to host or FQDN name
correctly, it may be more robust adding this line here:

$name ||= '?';

> print "$address:$port -> $name:$port\n";
> }
>
>__END__


--
..: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Want to write a script to do the batch conversion from domain name to IP. Hongyi Zhao Python 6 01-31-2009 09:44 AM
batch tiff to jpeg conversion script rtilley@vt.edu Python 11 01-30-2006 03:50 AM



Advertisments