Run the Ping command in ASP and return the result.
Source: Internet
Author: User
Run the Ping command in ASP and return the result.
In the Win2000 system, you can run the command through the Exec method of the Wscript. Shell object,
The simple code is as follows:
<% Response. Buffer = true %>
<%
Url = "www.topronet.com"
Set ob1_shell = CreateObject ("WScript. Shell ")
Set objCmd = obw.shell. Exec ("ping" & url)
StrPResult = objCmd. StdOut. Readall ()
Set objCmd = nothing: Set ob1_shell = nothing
StrStatus = "offline"
If InStr (strPResult, "TTL =")> 0 then strStatus = "online"
WqlQuery = "SELECT StatusCode FROM Win32_PingStatus WHERE Address "&_
"= '" & Url &"'"
Set PingResult = GetObject (WMI). ExecQuery (wqlQuery, "WQL", 48)
Response. write url & "status"
For Each result in PingResult
If clng (result. StatusCode)> 0 then
Response. write "offline"
Else
Response. write "online"
End if
Next
%>
Of course, we can also compile the corresponding components or use some ready-made components to implement such functions,
I will not talk about it here.
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