DNS Lookup program with ASP-Application tips

Source: Internet
Author: User
Tags servervariables nslookup
Operating environment, NT (SERVER, WORKSTATION), W2K
Need to install WSH2.0 or later on the server
If your system does not currently have WSH2.0 installed, you can download it from the following address
Http://www.microsoft.com/msdownload/vbscript/scripting.asp
It contains WSH2.0.
Below is the source code
<%@ language= "VBScript"%>
<% Option Explicit%>
<%
If Request.Form ("frmhost") = "" Then
' Set the initial value
StrIP = Request.ServerVariables ("REMOTE_ADDR")
Else
StrIP = Request.Form ("Frmhost")
End If
%>
<title>dns Lookup [v 1.0]</title>
<body bgcolor= "#FFFFFF" >
<form method= "POST" name= "Frmrdns" >
<label for= "Frmhost" ><u>Host:</u></label>
<input type= "text" name= "Frmhost" id= "Frmhost"
Value= "<%= StrIP%>" >
<input type= "button" Name= "Btnsubmit" id= "btnsubmit"
Value= "Lookup" onclick= "Document.frmRDNS.submit ()" >
</form>
<font face= "Arial" size= "2" color= "#003366" >
<%
Rmethod = UCase (Request.ServerVariables ("Request_method"))
If Rmethod = "POST" Then
' Lookup Host
Strreturn = NsLookup (StrIP)
If strreturn <> "" Then
Response.Write Strreturn
Else
' A Lame host is any Valid host that DNS cannot Resolve
' InterNIC for Details
Response.Write "<b>lame host-could not Resolve DNS for" _
& StrIP & "</b><br>"
End If
End If
Function NSlookup (Strhost)
' Create Shell Object
Set Oshell = Server.CreateObject ("Wscript.Shell")
' Run NSLookup via Command Prompt
' Dump Results into a temp text file
Oshell.run "%comspec%/C nslookup" & Strhost _
& "> C:\" & strhost & ". txt", 0, True
' Open the temp Text File and Read out the ' Data
Set OFS = Server.CreateObject ("Scripting.FileSystemObject")
Set OTF = Ofs.opentextfile ("C:\" & strhost & ". txt")
TempData = Null
Data = Null
i = 0
Do as not Otf.atendofstream
Data = Trim (otf.readline)
If i > 2 Then ' Don ' t want to display the local DNS Info.
TempData = tempdata & Data & "<BR>"
End If
i = (i + 1)
Loop
' Close it
Otf.close
' Delete It
Ofs.deletefile "C:\" & strhost & ". txt"
Set OFS = Nothing
NsLookup = TempData
End Function
%>
</font>
</body>
The code is very simple, I do not say, if you have any questions about WSH, please go to download WSH electronic document Chinese version of the chinaasp download area.
I hope I can be of some help to you.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.