I am using the following code to run ping and tracert commands from a browser. Thanks to DexStar for the code. This works great, but it is pretty slow to respond, since it waits to complete the operation before painting the screen. Can this be modified to paint line-by-line results as they occur in order to speed up the process?
<%@ LANGUAGE="VBSCRIPT" %>
Dim WshShell : Set WshShell = Server.CreateObject("WScript.Shell")
' Turn on Page Buffering for better results
Response.Buffer = True
Sub ExecCMD( strExec, strTitle )
Dim proc, n
' Write the title, and send it to the browser
Response.Write "<H1>" & strTitle & "</H1>"
' Execute the command and wait for it to finish
Set proc = WshShell.Exec( strExec )
Do While proc.Status = 0
' Anyone know a better way to wait? WScript.Sleep doesn't work in ASP
n = n + 1
' Write the results, and send it to the browser
Response.Write "<pre>" & proc.StdOut.ReadAll & "</pre>"
<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
Dim strIP : strIP = Request.QueryString("IP")
If ( strIP & "" <> "" ) Then
If ( InStr(strIP, " ") = 0 ) Then
ExecCMD "cmd /c ping " & strIP, "Ping Results"
ExecCMD "cmd /c tracert " & strIP, "Trace Route Results"
Response.Write "Bad H4x0r, No Ping Flood!"
Response.Write "No IP provided!"