繁體中文 
您当前的位置:维维资讯中心站长学院网络编程ASP编程 → 新闻内容 退出登录 用户管理
推荐资讯
相关资讯
推荐软件
热门资讯
热门软件下载
怎样在ASP中实现PING
作者:佚名  来源:网络整理  发布时间:2008-6-9 11:30:10

使用WSH调用系统的Ping命令,将Ping的结果重定向到一个文本文件中去,再把文本文件显示到网页中 
  具体做法如下:首先,建一个.BAT文件(例如:myPing.BAT:),这个文件要在ASP中调用,文件代码如下:ping -a %1 > d:INetPubcgi-bin%2.txt (%1)是将来要ping的地址, (%2)是存储ping结果的文件.以下是ASP的代码
  <%Set FileSys = Server.CreateObject("Scripting.FileSystemObject")FileName = FileSys.GetTempName 
  Set WShShell = Server.CreateObject("WScript.Shell") 
  IP = "xxx.xxx.xxx.xxx" '你要ping的地址RetCode = WShShell.Run("d:Inetpubcgi-binmyPing.bat " & IP & " " & FileName, 1, True) 
  if RetCode = 0 Then'没有错误elseResponse.Redirect "PingErrors.htm"end if 
  Set TextFile = FileSys.OpenTextFile("d:InetPubcgi-bin" & FileName & ".txt", 1)TextBuffer = TextFile.ReadAll 
  For i = 1 to Len(TextBuffer) 
  If Mid(TextBuffer,i,1) = chr(13) Then 
  Response.Write("<BR>") 
  else 
  Response.Write(Mid(TextBuffer,i,1)) 
  end if 
  Next 
  TextFile.Close 
  FileSys.DeleteFile "d:Inetpubcgi-bin" & FileName & ".txt" 
  %>

[] [返回上一页] [打 印]
新闻评论 (评论内容只代表网友观点,与本站立场无关!)

用户名: 查看更多评论

分 值:100分 85分 70分 55分 40分 25分 10分 0分

内 容:

         (注“”为必填内容。) 验证码: 验证码,看不清楚?请点击刷新验证码