Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Think about Loose Coupling
 
PerlMonks  

Re: Re: Re: Re: Ping and Tracert

by qball (Beadle)
on Aug 31, 2001 at 19:56 UTC ( [id://109524]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: Re: Re: Ping and Tracert
in thread Ping and Tracert

Hey, I'm getting blanks for my times. I'm running the same script, but receiving the following output:
High to low ms Highest ms Lowest ms

Thanks.

qball~"I have node idea?!"

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Ping and Tracert
by tachyon (Chancellor) on Aug 31, 2001 at 20:11 UTC

    What text does ping return? On Win32 it returns blah blah blah time=123ms so we match on the "time=123ms" bit. If the ping output format is different (as it will be on *nix) you just need to modify the regex. Post some sample ping output as captured by this sort of call (or whatever you are using) $ping = `ping`; print $ping and it will be easy to munge the times out of the return strings.

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      This is running on Linux.
      $ip = 'www.perlmonks.org'; $ping = `ping -c 3 $ip`; @times = $ping =~ /time=(\d+\.\d+)/; @times = sort { $b <=> $a } @times; print "High to low @times ms\n"; print "Highest $times[0] ms\n"; print "Lowest $times[-1] ms\n"; print "This was the reply parsed\n$ping\n";
      And here are the results.
      High to low 87.719 ms Highest 87.719 ms Lowest 87.719 ms This was the reply parsed PING www.perlmonks.org (206.170.14.76) from 207.16.70.63 : 56(84) byte +s of data. 64 bytes from yoda.blockstackers.com (206.170.14.76): icmp_seq=0 ttl=2 +38 time=87.719 msec 64 bytes from yoda.blockstackers.com (206.170.14.76): icmp_seq=1 ttl=2 +38 time=81.823 msec 64 bytes from yoda.blockstackers.com (206.170.14.76): icmp_seq=2 ttl=2 +38 time=82.001 msec --- www.perlmonks.org ping statistics --- 3 packets transmitted, 3 packets received, 0% packet loss round-trip min/avg/max/mdev = 81.823/83.847/87.719/2.758 ms
      It's not giving me the right data in the highest, lowest and highest to lowest. Please help.

      Thanks

      qball~"I have node idea?!"

        You have lost the /g off my regex when you modified it so you only match the first time=87.719 Thus the array only gets this one element. The /g makes it match all the time=nn.nnn and return them to the array. Make the regex @times = $ping =~ /time=(\d+\.\d+)/g; like it was and it will work fine. BTW if you use a char class like this /time=([\d\.]+)/g you are more flexible as you don't insist on the decimal point.

        cheers

        tachyon

        s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://109524]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.