How to terminate tracepath when no-reply is returned?
I'm writing a shell scrip开发者_如何学Pythont (in Linux) to try to find all the IP address from one machine to another. Right now I'm scanning the network by limit the range of the possible IP addresses, but it won't be 100% accurate. There will be times hitting IP address that doesn't exists, when using tracepath 192.x.x.x
will return me a long list of no-reply
rather than waiting for it to eventually timeout. How do I quickly stop the current tracepath
command inside a shell script ?
Is there anyway to read the output of the tracepath and detects if "no-reply
" is returned, if so terminate the current tracepath
IP address and moving on to the next one ?
You could try using expect
to monitor the output of tracepath
and do something when "no-reply" came out of it. Or maybe consider using traceroute
which allows you to specify a maximum number of hops.
精彩评论