欢迎光临
我们一直在努力

用ASP做的DNS LOOKUP程序

建站超值云服务器,限时71元/月

文章转译自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 dont 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下载区就有的吧

希望能对你有所帮助。

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 用ASP做的DNS LOOKUP程序
分享到: 更多 (0)