当前主题: 软件编程

asp执行ping命令

作者:Kaka    时间:2009-9-6 22:49:2    浏览:    评论:0

      用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

上一篇: ibm笔记本突然连不上无线网络的解决方法
下一篇: asp.net(c#)中实现ping功能

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

Powered By Z-Blog 1.8 Walle Build 91204 Designed by Han'space

Copyright @2009 All Rights Reserved. 粤ICP备09073737号