How to implement Ping in ASP
Use WSH to call the system's ping command, redirect the Ping's results to a text file, and then display the text file to the Web page
The following are specific practices:
First, build one. BAT file (for example: Myping.bat:), this file is to be called in ASP, the file code is as follows:
Ping-a%1 > D:\INetPub\cgi-bin\%2.txt
(% 1) is the address to ping in the future, (% 2) is the file that stores ping results. The following is the code for ASP:
<%
Set Filesys = Server.CreateObject ("Scripting.FileSystemObject")
FileName = Filesys.gettempname
Set WshShell = Server.CreateObject ("Wscript.Shell")
IP = "xxx.xxx.xxx.xxx" ' you want to ping the address
RetCode = Wshshell.run ("D:\Inetpub\cgi-bin\myPing.bat" & IP & "" & FileName, 1, True)
If RetCode = 0 Then
' No mistakes
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 Then
Response.Write ("<BR>")
Else
Response.Write (Mid (textbuffer,i,1))
End If
Next
Textfile.close
Filesys.deletefile "d:\Inetpub\cgi-bin\" & FileName & ". txt"
%>
My heart is flying