ASP调用系统ping命令代码
时间:2008-04-27 20:45:00
使用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
’没有错误
else
Response.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"
% >
标签:ping,命令,asp
0
投稿
猜你喜欢
asp防止盗链HTTP_REFERER判断代码
2010-03-12 10:41:00
Css Reset(复位)整理
2008-09-09 21:58:00
asp获取文件md5值
2008-10-13 09:10:00
javaScript通用数据类型校验函数
2009-07-06 12:49:00
用js更好地截取定长字符串
2008-01-16 12:48:00
OraclePL/SQL单行函数和组函数详解
2010-07-28 13:02:00
如何提示用户打开Cookie?
2010-06-07 20:53:00
PJBlog3优化——301定向跳转解决重复内容的问题
2009-05-20 10:40:00
使用SSIS创建同步数据库数据任务的方法
2012-11-30 19:53:44
SQLSERVER 创建索引实现代码
2012-04-13 12:17:05
asp读取数据库中数据到数组的类
2007-09-16 18:19:00
DW MX 的快键一览表
2009-07-21 12:47:00
ASP实例:即时显示当前页面浏览人数
2008-04-19 22:02:00
使用模板实现ASP代码与页面分离
2008-09-12 16:07:00
Yahoo!网站性能最佳体验的34条黄金守则—内容
2008-05-13 12:14:00
跨浏览器实现float:center,No CSS hacks
2008-08-22 12:59:00
浅谈web分析
2008-12-02 15:52:00
SQL集合函数中case when then 使用技巧
2011-09-30 11:54:59
EXEC(EXECUTE)函数访问INSERTED或DELETED的内部临时触发表
2012-01-29 18:07:30
讲解Access数据库中数据表的自动重新联接
2008-11-28 16:29:00