I’d like to write a parsing script in Perl that prints all the “interface name” from these bunch of data:
interfaces.ifTable.ifEntry.ifDescr.1 : OCTET STRING- (ascii): (hex): length = 30
0: 53 6f 66 74 77 61 72 65 20 4c 6f 6f 70 62 61 63 Software Loopbac
16: 6b 20 49 6e 74 65 72 66 61 63 65 20 31 00 -- -- k Interface 1...
interfaces.ifTable.ifEntry.ifDescr.2 : OCTET STRING- (ascii): (hex): length = 20
0: 57 41 4e 20 4d 69 6e 69 70 6f 72 74 20 28 53 53 WAN Miniport (SS
16: 54 50 29 00 -- -- -- -- -- -- -- -- -- -- -- -- TP).............
interfaces.ifTable.ifEntry.ifDescr.3 : OCTET STRING- (ascii): (hex): length = 20
0: 57 41 4e 20 4d 69 6e 69 70 6f 72 74 20 28 4c 32 WAN Miniport (L2
16: 54 50 29 00 -- -- -- -- -- -- -- -- -- -- -- -- TP).............
I’d like to extract all the three interfaces’ name out, as (“Sotware Loopback Interface 1”, “WAN Miniport (SSTP)”, “WAN Miniport (L2TP)”), and do further processing. I tried using regular expression but without luch. Is there any simple way to do this? Thanks in advance!
This is yet another dirty perl script. Read your data into $text however you wish. The regular expression looks for the pattern of each hex dump line. The join line then recombines the hex values back into the string and appends it to the current accumulated interface name. mttrb’s is simpler. 😉
To explain the join line, the following things occur in that line.