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...

use 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>';
Resolver.htm
<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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.