用ASP做的DNSLOOKUP程序
2023-06-13 09:13:54 时间
运行环境,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下载区就有的吧
希望能对你有所帮助。
服务器上需要安装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 MVC间歇性响应缓慢
- IIS 运行ASP文件500内部错误解决方法大全
- 优雅的Linux ASP编程之旅(linux.asp)
- ASP.NET WebForm也可以这样用Ajax(程序猿,你知道不)
- ASP搭配MySQL 配置惊艳不凡(asp连接mysql配置)
- 教你如何用ASP连接MySQL(asp连接mysql教程)
- 使用 ASP 实现 MySql 数据库的分页功能(asp连接mysql分页)
- 优雅的结合ASP与MySQL的SQL语句(asp和mysql语句)
- ASP操作MySQL简易指南轻松删除记录(asp删除记录mysql)
- ASP程序使用Oracle数据库实现智能化管理(asp 操作oracle)
- ASP程序开发探索之oracle数据库(asp和oracle)
- ASP与Oracle配合实现数据写入(asp oracle写入)
- Oracle ASP程序助你轻松下载(oracle asp下载)
- 用ASP实现对MP3曲目信息的操作
- ASP编程入门进阶(十一):Chat聊天程序
- 提高ASP效率的五大技巧
- ASP.NET绑定DataSet中的多个表
- ASP.NET用户多次登录的解决方法
- discuz2.0整合asp系统,用户添加函数
- asp.net程序在调式和发布之间图片路径问题的解决方法
- asp.net下使用DbProviderFactories的数据库操作类
- 修改服务器配置让asp.net文件后缀名随心所欲
- .Net中导出数据到Excel(asp.net和winform程序中)
- Asp.net之TextBox只允许输入数字的方法总结
- ASP.NETGridview中使用checkbox删除的2种方法实例分享
- asp.net得到本机数据库实例的两种方法代码
- 在ASP.NET中支持断点续传下载大文件(ZT)源码
- ASP.Net下载大文件的实现方法
- asp.net实现access数据库分页的方法