首页 >> 读书频道 >> 电脑 >> 怎样使用ASP实现Ping
 
· 友情连接浏览器
· 结束ADOVB.INC的
· 介绍一下GETROWS的
· 利用MSCHART画图的
· 可以近视替代remote
· 关于打印页面的一些经验
· 将HTML表单数据存储为
· 数据排序及如何动态排序
· 连接各种数据库的代码的总
· 用VB6创建MTS组件
· vbscript和jav
· 转换文本为超联和Emai
 
· 美容养颜手册
· 加油金顺剧情分集介绍完整
· 红楼梦:120回全本[清
· 素质教育在美国
· 全唐诗卷四十六
· 韩剧《布拉格恋人》剧情介
· 夜航船[作者:明·张岱]
· 局外人[作者:韩·可爱淘
· 现场流行病学
· 源氏物语[日本:紫式部]
· 武林寓言故事
· 2006高考录取规则
 
· (出租)中动商场部分及写
· (出租)中动动漫基地&#
· 喜剧学院
· 《善德女王》剧情介绍
· 魔女18号 剧情
· 丑女无敌剧情介绍
· 魔女幼熙剧情介绍
· 龙游天下剧情介绍
· 震撼世界的七日剧情介绍
· 静静的白桦林剧情介绍
· 心情日记—老公今天我想对
· 旗舰剧情介绍
欢迎来到月影社区!如果您觉得这里不错,请推荐给您的朋友们。月影社区:http://wf66.com/

怎样使用ASP实现Ping


查看有无更新版本

关键字:ASP技巧 2006-9-8

 

This article presents a simple way to ping an address and get the results of the ping using ASP. The idea was supplied by Bart Silverstein.
First, a .BAT file needs to be created that will be run from the Active Server Page. Let's call this file DoPing.BAT. It will contain only one statement, which will ping a passed in IP address. Here is the code for DoPing.BAT:

ping -a %1 > d:\INetPub\cgi-bin\%2.txt
This will, if you can't tell, ping the address passed in as the first command line argument (%1), and redirect the results to a text file named hy the second command line argument (%2). Now, let's look how we would call this from an ASP file:

<%
Set FileSys = Server.CreateObject("Scripting.FileSystemObject")
FileName = FileSys.GetTempName
Set WShShell = Server.CreateObject("WScript.Shell")
IP = "204.123.54.1" ' or whatever you want to ping
RetCode = WShShell.Run("d:\Inetpub\cgi-bin\DoPing.bat " & IP & " " & FileName, 1, True)
if RetCode = 0 Then
'There were no errors
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("<BR>")
else
Response.Write(Mid(TextBuffer,i,1))
end if
Next
TextFile.Close
FileSys.DeleteFile "d:\Inetpub\cgi-bin\" & FileName & ".txt"
%>
Before you go hog wild and implement this code or use similar techniques on your site, there are a few things you should be wary of. From a secutiry standpoint, this is really dangerous, for any time you let someone run an application on your server there is always the potential that it will come back to haunt you. One suggestion to lessen the threat: make a separate folder with no script or execute priviledges, and have your DoPing.bat output its results to that folder.
I hope this article was informative an interesting. Happy Programming!

怎样使用ASP实现Ping

[ 1 ]
怎样使用ASP实现Ping num

打印本页 关闭

关于我们版权声明本站导航友情连结作品演示 TOP↑