Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ping computer returns what?

Status
Not open for further replies.

pugs421

Technical User
Nov 25, 2002
114
US
I found this code which pings a machine:

ipVar = "ping 192.168.3.107"
Set objShell = CreateObject("WScript.Shell")
objShell.run ipVar

But how do I deal with what it returns? In other words if a computer has crashed and is not able to be pinged, then I need to send a message to another machine.

Thanks
 
More clarification-

I only need to know how to tell whether the ping was successful or not.
 
Hello pugs421,

You can simply catching a signature string to your satisfaction. I would say, "TTL" would be a satisfactory signature.
Code:
surl="[URL unfurl="true"]www.google.com"[/URL]
signature="TTL"

set wshshell=createobject("wscript.shell")
set oexec=wshshell.exec("ping " & surl)
do while oexec.status=0 : wscript.sleep 100 : loop
soutput=oexec.stdout.readall
if instr(1, soutput, signature, 1)<>0 then
	wscript.echo "The url is alive."
else
	wscript.echo "The url is unavailable or unknown; or the response is blocked."
end if
set oexec=nothing : wshshell=nothing
regards - tsuji
 
correction:

Last line of course is:

[tt]set oexec=nothing : [red]set[/red] wshshell=nothing[/tt]

Typed too hastily!

- tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top