用ASP做的DNS LOOKUP程序
2001-02-19 10:58:59 来源:WEB开发网核心提示:文章转译自asp101运行环境,NT(SERVER、WORKSTATION)、W2K服务器上需要安装WSH2.0或者更高版本如果您的系统目前没有安装WSH2.0,用ASP做的DNS LOOKUP程序,您可以从以下这个地址去下载它http://www.microsoft.com/msdownload/vbscript/s
文章转译自asp101
运行环境,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
%>
<html>
<head>
<title>DNS Lookup [v 1.0]</title>
</head>
<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
' See 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 While Not oTF.AtEndOfStream
Data = Trim(oTF.Readline)
If i > 2 Then ' Don't want to display 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>
</html>
代码很简单,我不多说了,如果您对WSH有什么疑问的话,请去下载WSH的电子文档中文版本的,CHINAASP下载区就有的吧
希望能对你有所帮助。
运行环境,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
%>
<html>
<head>
<title>DNS Lookup [v 1.0]</title>
</head>
<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
' See 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 While Not oTF.AtEndOfStream
Data = Trim(oTF.Readline)
If i > 2 Then ' Don't want to display 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>
</html>
代码很简单,我不多说了,如果您对WSH有什么疑问的话,请去下载WSH的电子文档中文版本的,CHINAASP下载区就有的吧
希望能对你有所帮助。
- ››asp.net页面弄成伪静态页面
- ››Asp.net 中将汉字转换成拼音的方法
- ››ASP.NET及JS中的cookie基本用法
- ››ASP.NET获取MS SQL Server安装实例
- ››asp.net实现调用百度pai 在线翻译英文转中文
- ››ASP.NET页面选项进行提示判断
- ››Asp.net定时执行程序
- ››ASP.NET中利用DataList实现图片无缝滚动
- ››ASP.NET验证控件RequiredFieldValidator
- ››ASP.NET中使用System.Net.Mail发邮件
- ››ASP.NET中获取用户控件中控件的ID
- ››ASP.NET中FileBytes写成文件并存档
更多精彩
赞助商链接