This takes an input of a machine name or an IP address, and checks to see if it exists and presents the name resolution. I included the script and the HTML page.
The coolest part of this (for me) was getting the name resolution down to one line. I couldn't have put this togther without bastardoperator and the other monks...
Resolver.htmuse CGI qw(:standard); print header(); print start_html('Resolved'); &resolve(); print param('xinput')." resolved to $new"; print end_html; #To resolve host names (xname) or IP(xip)... sub resolve{ if (param('xinput')=~/^\D/){ # if begins with a letter assume it's + a name $new=join('.',(unpack("C4", gethostbyname(param('xinput'))))); }elsif (param('xinput')=~/^\d/){ # if begins with a number assume +it's an IP $new=gethostbyaddr(pack("C4", (split(/\./, param('xinput')))), + AF_INET); } if (($new eq null)||($new eq "")){ print "Could not resolve.\n"; die "Could not resolve.\n"; } } print "<p><a href=".referer().'>back</a></p>';
<HTML> <HEAD> <TITLE>Name Resolution</TITLE> </HEAD> <BODY> <FORM ACTION=scripts/resolver.pl method=post> <P>Enter an IP address or Machine name:<BR> <INPUT NAME=xinput VALUE=""></P> <P><INPUT TYPE=SUBMIT value="Resolve"> </FORM> </BODY> </HTML>
In reply to Not so cool name resolution by OzzyOsbourne
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |