Hi all, I have 3 files each of which are space delimited sets of data. I have to cross-reference these files to get one set of data at the end. The first file maps IP Address to Cisco ATM interface, the second maps IP Address to MAC Address, and the third maps Cisco ATM interface to actual VPI and VCI. I need to map MAC Address to VCI/VPI. Here is a sample of each file: 24.121.58.91 0.32 24.121.57.11 0100.0f66.2b81.5f 0.2 1 33 I was thinking of using awk, but I am not sure how to tell awk to keep an array for each line of 2 files (let alone 3). Any shell script guru's care to lend some advice? Thanks, Brad --
Brad wrote:
Hi all,
I have 3 files each of which are space delimited sets of data. I have to cross-reference these files to get one set of data at the end. The first file maps IP Address to Cisco ATM interface, the second maps IP Address to MAC Address, and the third maps Cisco ATM interface to actual VPI and VCI. I need to map MAC Address to VCI/VPI. Here is a sample of each file:
24.121.58.91 0.32 24.121.57.11 0100.0f66.2b81.5f 0.2 1 33
I was thinking of using awk, but I am not sure how to tell awk to keep an array for each line of 2 files (let alone 3). Any shell script guru's care to lend some advice?
I'd use associative arrays in Perl or dicts in Python. Trying to do this in awk would be painful. BTW, is there a way to get this out of IOS directly (assuming you're using an IOS-based device)?
I'd use associative arrays in Perl or dicts in Python. Trying to do this in awk would be painful.
BTW, is there a way to get this out of IOS directly (assuming you're using an IOS-based device)?
_______________________________________________ Kclug mailing list Kclug@kclug.org http://kclug.org/mailman/listinfo/kclug
-- I had considered Perl, maybe I will give that another look. There is no way I know of to get this out of the IOS, but if someone can correct me on this please do. Thanks, Brad
On 4/18/05, Brad <brad@bradandkim.net> wrote:
Hi all,
I have 3 files each of which are space delimited sets of data. I have to cross-reference these files to get one set of data at the end. The first file maps IP Address to Cisco ATM interface, the second maps IP Address to MAC Address, and the third maps Cisco ATM interface to actual VPI and VCI. I need to map MAC Address to VCI/VPI. Here is a sample of each file:
24.121.58.91 0.32 ip to if 24.121.57.11 0100.0f66.2b81.5f mac to ip 0.2 1 33 if to data
I was thinking of using awk, but I am not sure how to tell awk to keep an array for each line of 2 files (let alone 3). Any shell script guru's care to lend some advice?
perl's associative arrays are ideal for this kind of thing, especially coupled with its easy line-based file primitives. open IP2IF, "ip_to_interface_file"; while (<IP2IF>){ /([0123456789\.]+)\s+([0123456789\.]+) or next; $ip2if{$1} = $2; }; repeat something like that for all three, then for (keys %mac2ip){ print "Mac Address $_ is handled on ", "Vdata $if2data{$ip2if{$mac2ip{$_}}}\n"; }; hope that helps -- David L Nicol $SesKey=join"",grep{/\w/}map{chr rand 128}0..99;#Zesty!
participants (3)
-
Brad -
David Nicol -
Gerald Combs