in reply to Ping and Tracert
Update: just for kicks, here's the above golfed down a bit :-)my @res = `ping -c 3 $ip`; if (pop @res =~ /(\d+\.\d+)\/(\d+\.\d+)\/(\d+\.\d+)) { my @sorted = sort ($1,$2,$3); print pop @sorted }
Also - regarding your question re: multiple OS's. That's the problem with non-modular code. Anyways, what I would suggest is that you set the command you will run earlier in the script depending on the os (ie $ping = "command" if $^O =~ /Solaris/ etc..print(((sort(((`ping -c3 $ip`)[-1])=~/(\d+\.\d+)\/(\d+\.\d+)\/(\d+\.\d ++)/))[-1]) )
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Ping and Tracert
by qball (Beadle) on Aug 31, 2001 at 22:20 UTC | |
by tachyon (Chancellor) on Aug 31, 2001 at 22:32 UTC | |
by qball (Beadle) on Aug 31, 2001 at 22:36 UTC | |
by tachyon (Chancellor) on Aug 31, 2001 at 22:39 UTC |