Jump to content

Recommended Posts

Posted (edited)

Hello, I would like to use RegEx to grab the results of a ping / traceroute.

]0;52183892@REPLACEDOMAIN.COM@replace-host-name01:~[52183892@REPLACEDOMAIN.COM@replace-host-name01 ~]$ ping -c 20 1.1.1.1
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
64 bytes from 1.1.1.1: icmp_seq=1 ttl=241 time=209 ms
64 bytes from 1.1.1.1: icmp_seq=2 ttl=241 time=209 ms
64 bytes from 1.1.1.1: icmp_seq=3 ttl=241 time=209 ms
64 bytes from 1.1.1.1: icmp_seq=4 ttl=241 time=209 ms
64 bytes from 1.1.1.1: icmp_seq=5 ttl=241 time=209 ms
64 bytes from 1.1.1.1: icmp_seq=6 ttl=241 time=209 ms
64 bytes from 1.1.1.1: icmp_seq=7 ttl=241 time=209 ms
64 bytes from 1.1.1.1: icmp_seq=8 ttl=241 time=209 ms
64 bytes from 1.1.1.1: icmp_seq=9 ttl=241 time=210 ms
64 bytes from 1.1.1.1: icmp_seq=10 ttl=241 time=209 ms
64 bytes from 1.1.1.1: icmp_seq=11 ttl=241 time=209 ms
64 bytes from 1.1.1.1: icmp_seq=12 ttl=241 time=209 ms
64 bytes from 1.1.1.1: icmp_seq=13 ttl=241 time=209 ms
64 bytes from 1.1.1.1: icmp_seq=14 ttl=241 time=209 ms
64 bytes from 1.1.1.1: icmp_seq=15 ttl=241 time=209 ms
64 bytes from 1.1.1.1: icmp_seq=16 ttl=241 time=210 ms
64 bytes from 1.1.1.1: icmp_seq=17 ttl=241 time=210 ms
64 bytes from 1.1.1.1: icmp_seq=18 ttl=241 time=210 ms
64 bytes from 1.1.1.1: icmp_seq=19 ttl=241 time=209 ms
64 bytes from 1.1.1.1: icmp_seq=20 ttl=241 time=209 ms

--- 1.1.1.1 ping statistics --- ; NEED
20 packets transmitted, 20 received, 0% packet loss, time 19023ms ; NEED
rtt min/avg/max/mdev = 209.788/209.957/210.451/0.303 ms ; NEED]0;52183892@REPLACEDOMAIN.COM@replace-host-name01:~[52183892@REPLACEDOMAIN.COM@replace-host-name01 ~]$ traceroute 1.1.1.1 -m 30 ; NEED
traceroute to 1.1.1.1 (1.1.1.1), 30 hops max, 60 byte packets ; NEED
 1  BIG-LONG-HOST_NAME-GOES_HERE (1.1.1.1)  98.838 ms  98.865 ms  98.970 ms ; NEED
 2  BIG-LONG-HOST_NAME-GOES_HERE-LIKE-IM-NOT-KIDDING_ITS\REALLY_LONG (1.1.1.1)  0.774 ms  0.789 ms  0.772 ms ; NEED
 3  * * * ; NEED
 4  * * * ; NEED
 5  * * * ; NEED
 6  BIG-LONG-HOST_NAME-GOES_HERE2 (1.1.1.1)  209.938 ms  209.823 ms  209.824 ms ; NEED
 7  BIG-LONG-HOST_NAME-GOES_HERE3 (1.1.1.1)  249.303 ms  210.545 ms  210.693 ms ; NEED (Assume this will go either 0-15 hops or 0-30 hops with it possibly ending up with * * * all the way to the end at any point from part start-end)]0;52183892@REPLACEDOMAIN.COM@replace-host-name01:~[52183892@REPLACEDOMAIN.COM@replace-host-name01 ~]$

I need the commented parts..

 

close? (?!64|bytes|from|packets)[\r\n]\s\d{1,2}.{1,}

Edited by rm4453
Fixed Paste / Updated Title
Posted (edited)

After messing with it I have the following:
\-\-\-.{1,}
\d\d.packets.{1,}
\@.{1,1000}traceroute.{1,}
traceroute to.{1,}

Which almost completes what I need...

Edited by rm4453
Posted (edited)

I ended up doing it this way instead:

 

$buf_collect_pointer = StringRegExp($buf_collect, "\-\-\-.{1,}", 1)
    $j = 0

    While $j < UBound($buf_collect_array) - 1

        If $buf_collect_array[$j] == $buf_collect_pointer[0] Then
            _ArrayDelete($buf_collect_array, "0-" & $j - 1)
        EndIf

        $j += 1

    WEnd

 

Edited by rm4453

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...