I have serveral Project Managers that like to look up ip address (have me
tell them what they are) for a specific host on the internet. Tired of all
the calls I decided to scratch up a quick cgi for the intranet, and,
initially,
I was using the 'host' of 'nslookup' command on the system, but I wanted to
try to do it with gethostbyname() function. I found an old script of mine
that works from the command line, and incorporated it into my script, but I
don't actually get the result of the gethostbyname() functions at all. Here
is the cgi script:
Can someone tell me why I am not getting a list of ip's from this posted to
the page?
Thanks!
-James
#!/usr/bin/perl
# This is a web based nslookup tool
# for people who don't have the tools
# or knowledge to use them.
use strict;
use CGI qw/:standard/;
require("./header.cgi");
require("./footer.cgi");
my $cgi = CGI->new();
my $host = param('host');
if($host) {
&get_header;
print $cgi->h2("Results..."),
&getadd;
&get_footer;
}
else {
&get_header;
print $cgi->h2("TAA nslookup utility");
print $cgi->start_form,
em("Enter the host name, i.e.,
\"warbaby.ashlandagency.com\""),br
,
textfield(-name=>'host'),br,
submit,reset;
&get_footer;
}
sub getadd {
my $host = shift(@_);
my $cgi = $cgi;
use Socket;
my ($name,$aliases,$addrtype,$length,@addrs) = gethostbyname($host);
foreach $a (@addrs) {
my $ipaddress = inet_ntoa($a);
print $cgi->em("$ipaddress");
}
}
sub cgidie {
my $message = shift(@_);
my $cgi = $cgi;
print $cgi->strong("$message");
&get_footer;
}
--
James Kelty
Sr. Unix Systems Administrator
The Ashland Agency
541.488.0801
[EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]