用asp获取ping值,可以通过Wscript.Shell对象的Exec方法执行命令,返回结果。
代码如下:
<% Response.Buffer = true %>
<%
url = "www.baidu.com"
Set objWShell = CreateObject("WScript.Shell")
Set objCmd = objWShell.Exec("ping " & url)
strPResult = objCmd.StdOut.Readall()
set objCmd = nothing: Set objWShell = nothing
response.write url
response.write ".<br>" & replace(strPResult,vbCrLf,"<br>")
%>
执行结果
www.baidu.com.
Pinging www.a.shifen.com [121.14.89.14] with 32 bytes of data:
Reply from 121.14.89.14: bytes=32 time=11ms TTL=57
Reply from 121.14.89.14: bytes=32 time=12ms TTL=57
Reply from 121.14.89.14: bytes=32 time=12ms TTL=57
Reply from 121.14.89.14: bytes=32 time=12ms TTL=57
Ping statistics for 121.14.89.14:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 11ms, Maximum = 12ms, Average = 11m
☉ASP HTTP组件下载、简单介绍、属性方法及使用范例【全】 (2009-8-3 1:40:45)
☉最简单的asp中调用存储过程的实例 (2009-8-1 11:41:50)
☉测试空间是否支持XMLHTTP组件 (2009-7-13 23:8:17)
☉测试空间是否支持ADODB.STREAM的方法 (2009-7-12 12:52:16)
☉asp获取网页源代码并处理乱码的方法 (2009-7-11 22:15:34)
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。