File: //proc/self/root/scripts.20110531.215904.25158/quickdnslookup
#!/usr/bin/perl
# cpanel - quickdnslookup Copyright(c) 2009 cPanel, Inc.
# All rights Reserved.
# copyright@cpanel.net http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited
use strict;
use Socket;
my $lookuptimeout = 10;
my $child = 0;
foreach my $name (@ARGV) {
if ( my $child <= 15 ) {
if ( my $pid = fork() ) {
$child++;
#master
}
else {
my $ip = iplookup($name);
print "$name=$ip\n";
exit;
}
}
else {
sleep 1;
}
while ( waitpid( -1, 1 ) > 0 ) {
$child--;
}
}
while ( waitpid( -1, 0 ) > 0 ) {
$child--;
}
sub iplookup {
my $domain = shift;
alarm($lookuptimeout);
return join( '.', unpack( 'C4', ( gethostbyname($domain) )[4] ) );
alarm(0);
}