当前位置:asp编程网>技术教程>Asp教程>  正文

用ASP做的DNS LOOKUP程序

2007-03-09 00:00:01   来源:   作者:   浏览量:1702   收藏
运行环境,NT(SERVER、WORKSTATION)、W2K
服务器上需要安装WSH2.0或者更高版本
如果您的系统目前没有安装WSH2.0,您可以从以下这个地址去下载它
http://www.microsoft.com/msdownload/vbscript/scripting.asp
里面包含了WSH2.0
下面是源代码
<%@ Language="VBScript" %>
<% Option Explicit %>
<%
If Request.Form("frmHost") = "" Then
    '设置初始值 
    strIP = Request.ServerVariables("REMOTE_ADDR")
Else
    strIP = Request.Form("frmHost") 
End If
%>


    DNS Lookup [v 1.0]



    Host:
            value="<%= strIP  %>">
            value="Lookup" onClick="document.frmRDNS.submit()">


<%
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
        ' See InterNic for Details
        Response.Write "Lame Host - Could Not Resolve DNS For " _
            & strIP & "

"
    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 While Not oTF.AtEndOfStream
        Data = Trim(oTF.Readline)
            If i > 2 Then ' Don't want to display local DNS Info.
                tempData = tempData & Data & "
"
            End If
        i = (i + 1)
    Loop
    'Close it
    oTF.Close
    'Delete It
    oFS.DeleteFile "C:" & strHost & ".txt"
    Set oFS = Nothing
    nsLookup = tempData
End Function
%>



代码很简单,我不多说了,如果您对WSH有什么疑问的话,请去下载WSH的电子文档中文版本的,CHINAASP下载区就有的吧
希望能对你有所帮助。

关于我们-广告合作-联系我们-积分规则-网站地图

Copyright(C)2013-2017版权所属asp编程网