Chinaunix首页 | 论坛 | 博客
  • 博客访问: 14523427
  • 博文数量: 5645
  • 博客积分: 9880
  • 博客等级: 中将
  • 技术积分: 68081
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-28 13:35
文章分类

全部博文(5645)

文章存档

2008年(5645)

我的朋友

分类:

2008-04-28 21:04:36

下载本文示例代码
  使用WSH调用系统的Ping命令,将Ping的结果重定向到一个文本文件中去,再把文本文件显示到网页中。 具体做法如下:  首先, 建一个.BAT文件(例如:myPing.BAT:),这个文件要在ASP中调用,文件代码如下:  ping -a %1 > d:\INetPub\cgi-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:\Inetpub\cgi-bin\myPing.bat " & IP & " " & FileName, 1, True) if RetCode = 0 Then'没有错误elseResponse.Redirect "PingErrors.htm"end if Set TextFile = FileSys.OpenTextFile("d:\InetPub\cgi-bin\" & FileName & ".txt", 1)TextBuffer = TextFile.ReadAll For i = 1 to Len(TextBuffer) If Mid(TextBuffer,i,1) = chr(13) Then Response.Write("") else Response.Write(Mid(TextBuffer,i,1)) end if Next TextFile.Close FileSys.DeleteFile "d:\Inetpub\cgi-bin\" & FileName & ".txt" %>   使用WSH调用系统的Ping命令,将Ping的结果重定向到一个文本文件中去,再把文本文件显示到网页中。 具体做法如下:  首先, 建一个.BAT文件(例如:myPing.BAT:),这个文件要在ASP中调用,文件代码如下:  ping -a %1 > d:\INetPub\cgi-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:\Inetpub\cgi-bin\myPing.bat " & IP & " " & FileName, 1, True) if RetCode = 0 Then'没有错误elseResponse.Redirect "PingErrors.htm"end if Set TextFile = FileSys.OpenTextFile("d:\InetPub\cgi-bin\" & FileName & ".txt", 1)TextBuffer = TextFile.ReadAll For i = 1 to Len(TextBuffer) If Mid(TextBuffer,i,1) = chr(13) Then Response.Write("") else Response.Write(Mid(TextBuffer,i,1)) end if Next TextFile.Close FileSys.DeleteFile "d:\Inetpub\cgi-bin\" & FileName & ".txt" %> 下载本文示例代码


如何在ASP中实现PING如何在ASP中实现PING如何在ASP中实现PING如何在ASP中实现PING如何在ASP中实现PING如何在ASP中实现PING如何在ASP中实现PING如何在ASP中实现PING如何在ASP中实现PING如何在ASP中实现PING如何在ASP中实现PING如何在ASP中实现PING如何在ASP中实现PING如何在ASP中实现PING如何在ASP中实现PING
阅读(167) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~