How to implement Ping in ASP (to Tracy)

Source: Internet
Author: User
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:inetpubcgi-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:inetpubcgi-binmyping.bat" & IP & "" & FileName, 1, True)
If RetCode = 0 Then
' No mistakes
Else
Response.Redirect "Pingerrors.htm"
End If
Set textfile = Filesys.opentextfile ("D:inetpubcgi-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:inetpubcgi-bin" & FileName & ". txt"
%>
My heart is flying
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.