请教高手:网页上能否实现类似ping命令的功能,就是检测某个IP的计算机是否连接

frankenstin 2004-04-28 03:55:35
单位上要做个计算机情况管理的数据库,个人想法,想加入一些检测连接等等的功能,不知道在技术上是否可行,想请教一下高手
...全文
219 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
wgd 2004-04-28
  • 打赏
  • 举报
回复
学习
frankenstin 2004-04-28
  • 打赏
  • 举报
回复
风语者的代码我已经测试过,没问题
家和万事兴,能否写一两段代码出来,或者是给个相关的文档都行。你这样说我实在是不知道该不该给你分啊……
cjf1009 2004-04-28
  • 打赏
  • 举报
回复
mark
ttt2 2004-04-28
  • 打赏
  • 举报
回复
用xmlhttp来作看他返回的状态即可
lawdoor 2004-04-28
  • 打赏
  • 举报
回复
ASP Ping 简要介绍

主页:http://www.serverobjects.com/
下载:http://www.serverobjects.com/comp/aspping.zip

AspPing提供命令行程序ping相同的基本功能,AspPing是免费的,没有免费的技术支持

安装:
将dll文件,拷贝到一个子目录,例如NT的目录\winnt\system32,win95/98的目录\windows\system.
注册dll文件,命令行将当前目录换到该目录,然后键入:
regsvr32 aspping.dll

简单实例:
使用这个组件十分简单
1.创建对象
2.设定一些属性
3.调用Ping方法

<%
rem ***********************************************************
rem * 创建对象
rem ***********************************************************
Set Pinger = Server.CreateObject("AspPing.Conn")

rem ***********************************************************
rem * 设定要ping的主机
rem ***********************************************************
Pinger.RemoteHost = "www.microsoft.com"

rem ***********************************************************
rem * ping远程主机的次数,可选
rem * 缺省值为 1
rem ***********************************************************
Pinger.PingCount = 2


rem ***********************************************************
rem * Ping 然后获得ping的结果
rem ***********************************************************
Response.Write "<pre>" & Pinger.Ping & "</pre>"

rem ***********************************************************
rem * 释放对象
rem ***********************************************************
Set Pinger = nothing

%>


AspPing的属性
RemoteHost - string 字符串
Blocksize - byte 字节
TTL - byte 字节
AspPing方法
Ping - 返回结果(字符串)
lawdoor 2004-04-28
  • 打赏
  • 举报
回复
如何在ASP中实现PING

使用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("<BR>")

else

Response.Write(Mid(TextBuffer,i,1))

end if

Next

TextFile.Close

FileSys.DeleteFile "d:\Inetpub\cgi-bin\" & FileName & ".txt"

%>

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧