Using TCL on Cisco IOS
Count the number of IP addresses found in a command output:
#Create regex for a single octet set OCTET_PAT {(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])} #Create regex pattern for a full ip address set IP_PAT "[join [list $OCTET_PAT $OCTET_PAT $OCTET_PAT $OCTET_PAT] {.}]" #Execute a command and look for regex matches and get count (-all) set num_ospf_nbrs [regexp -all -nocase -line $IP_PAT [ exec "sho ipv6 ospf neigh | ex OSPF"] all ] puts "Number of ipv6 ospf neighbors: $num_ospf_nbrs"
0 Comments
Log in with Twitter, Google, Facebook, LinkedIn to leave a comment.