Is it possible to run a specific script and receive a message (like msg command) when the pinged machine becomes available?
ping -n <Address> | find "TTL=" && (
msg * Online
)
CodePudding user response:
Here is a PowerShell way:
ping -t <Address> | Select-String 'TTL=' | Select-Object -First 1
msg * Online
ping -t <Address>
repeatedly pings the given host.Select-String 'TTL='
searches each output line ofping
for the given RegEx pattern. If found, it is piped to the next command.Select-Object -First 1
ends the pipeline as soon as the first line has been found.- This outputs the line containing "TTL=" to the console. If you don't want this, append
| Out-Null
.