I'm looking for pointers on what to do next. I have a file (the output
from 'show cdp neighbors detailed' on a Cisco router. I created a short
program which captures the output to a file - looks something like
this...
CDP log for ca5gw001.winstar.com
Created: 22:00:29 - 2001/08/01
-------------------------
Device ID: ca5gw002.winstar.com
Entry address(es):
IP address: 10.1.25.3
Platform: cisco 4700, Capabilities: Router
Interface: Ethernet3/0, Port ID (outgoing port): Ethernet0
Holdtime : 167 sec
Version :
Cisco Internetwork Operating System Software
IOS (tm) 4500 Software (C4500-JS-M), Version 11.3(7), RELEASE SOFTWARE
(fc1)
Copyright (c) 1986-1998 by cisco Systems, Inc.
Compiled Tue 01-Dec-98 17:26 by kpma
-------------------------
Device ID: ca24gw001.winstar.com
Entry address(es):
IP address: 10.0.252.141
Platform: cisco 2610, Capabilities: Router
Interface: Serial2/2, Port ID (outgoing port): Serial0/0
Holdtime : 156 sec
...
The first two lines are created during the capture and I hope to use
them as some sort of an ID.
Now I'd like to pull some key information from this file and set up a
table. I figured out how to read the file as a single string, strip the
newlines and double spaces and then split on the '---------' so I can
now address each record as part of an array.
Here is $B[1]:
Device ID: wa2gw001.winstar.com Entry address(es): IP address:
10.0.249.117 Platform: cisco 7206VXR, Capabilities: Router Interface:
Hssi11/1/0.174, Port ID (outgoing port): Serial2/2.105 Holdtime : 121
sec Version : Cisco Internetwork Operating System Software IOS (tm) 7200
Software (C7200-IS-M), Version 12.0(7)T, RELEASE SOFTWARE (fc2)
Copyright (c) 1986-1999 by cisco Systems, Inc. Compiled Tue 07-Dec-99
16:36 by phanguye advertisement version: 2
The next step would be to pull out the info without all the extraneous
information. The output should eventually look something like (separated
with tabs):
ca5gw001 E3/0 ca5gw002 E0 10.1.25.3 4700 router
11.3(7), fc1
ca5gw001 S2/2 ca24gw001 S0/0 10.0.252.141 2610
router 12.0(4)T, fc1
...
I'm not coming close to a general way to pull this information out of
each array element. I figure I have to use regular expressions to match
the info I want - maybe use $1, $2, $3... if I can figure out what to
match.
This post is long enough. If anyone's interested, I could post the code
fragments I've come up with so far.
I've got the Perl CD Bookshelf - just can't put it into practice yet.
Thanks,
Kevin
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]