$cdp = "Device-ID (0x01), length: 44 bytes: 'my-switch-name' Address (0x02), length: 13 bytes: IPv4 (1) 10.1.1.10 Port-ID (0x03), length: 16 bytes: 'Ethernet101/1/20' Capability (0x04), length: 4 bytes: (0x00000228): L2 Switch, IGMP snoo +ping Version String (0x05), length: 66 bytes: Cisco Nexus Operating System (NX-OS) Software, Version 5.2(1)N1(3) Platform (0x06), length: 11 bytes: 'N5K-C5596UP' Native VLAN ID (0x0a), length: 2 bytes: 911 AVVID trust bitmap (0x12), length: 1 byte: 0x00 AVVID untrusted ports CoS (0x13), length: 1 byte: 0x00 Duplex (0x0b), length: 1 byte: full MTU (0x11), length: 4 bytes: 1500 bytes System Name (0x14), length: 11 bytes: 'my-switch-name' System Object ID (not decoded) (0x15), length: 14 bytes: 0x0000: 060c 2b06 0104 0109 0c03 0103 880e Management Addresses (0x16), length: 13 bytes: IPv4 (1) 10.151.69.11 Physical Location (0x17), length: 13 bytes: 0x00/snmplocation"
And set VLAN to 911. But I just cannot see how to do it with Perl even though it is almost certainly ridiculously straight forward. my @switch = ( $cdp =~ m/0x01/ ); Isn't working and any assistance gratefully received.VLAN=`echo $cdp | awk '/0x0a/ { print $8 }'`
In reply to Regular expression assistance by agentorange
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |