用ASP做的DNS LOOKUP程序
程序员文章站
2023-11-04 20:51:10
运行环境,nt(server、workstation)、w2k 服务器上需要安装wsh2.0或者更高版本 如果您的系统目前没有安装wsh2.0,您可以从以下这个地址去下载它...
运行环境,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下载区就有的吧
希望能对你有所帮助。