Program article translated from ASP101
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 more, if you have any questions about WSH, please go to download WSH electronic documents
In the Chinese version, the chinaasp download area is available.
I hope I can be of some help to you.