#! c:/perl/bin/perl.exe # use strict; use vars qw/@Showtech_Log/; print "\nScript: $0\n"; if (open(FILE,"c:\\showtech217.txt")) { $/='*' x 66; @Showtech_Log =; close FILE; } else { die "\n$!\tc:\\showtech217.txt\n"; } ##################### Main Loop ###################### for my $data (@Showtech_Log) { my $Port_Channel; my $Port_Channel_Details; my $Interface; my $Interface_Details; ##################### Switch Name ####################### if ( $data =~ /show switchname -+\n(\w+)/) { print "\nSwitch Name: $1\n"; } ##################### Clock Time/Date ##################### if ($data =~ /show clock -+\n(.+)/) { print "\nClock: $1\n"; } ##################### Port-Channel DB ##################### if ($data =~ /show port-channel database/) { my @temp = split (/\n+/,$data); for (@temp) { $Port_Channel = $1 , next if (/port-channel (\d+)$/); $Port_Channel_Details->{$Port_Channel}->{$1} = $2 if (m|(fc\d+/\d+)\s+\[(\w+)\]|); } } ##################### Running-Config ###################### if ($data =~ /show running-config/) { my @temp = split (/\n+/,$data); for (@temp) { $Interface = $1, next if (/interface port-channel (\d+)$/); $Interface_Details->{$Interface}->{$1} = $2 if (/switchport description To (\w+) ([\d\.]+)/); } } for my $Port (keys %{$Port_Channel_Details}) { print "\nPort Channel $Port : \n"; for my $channels (keys %{$Port_Channel_Details->{$Port}}) { print "\t$channels [$Port_Channel_Details->{$Port}->{$channels}]\n"; } } for my $Interface_Port (keys %{$Interface_Details}) { print "\nInterface Port Channel $Interface_Port : \n"; for my $Interface_Channel (keys %{$Interface_Details->{$Interface_Port}}) { print "\t$Interface_Channel : $Interface_Details->{$Interface_Port}->{$Interface_Channel}\n"; } } ##################### FLOGI DB ######################### if ($data =~ /show flogi database/) { print "\n"; my @temp = split (/\n/,$data); for (@temp) { #print "$_\n" if (/^fc/); } } } #### Script: C:\Scripts\array3.pl Switch Name: CCC217_ANG_GREEN Clock: Fri Sep 23 11:14:42 UTC 2005 Port Channel 1 : fc2/5 [up] fc1/5 [up] Port Channel 3 : fc1/1 [up] Interface Port Channel 1 : CCC219 : 10.33.81.56 Interface Port Channel 3 : CCC215 : 10.33.81.52 #### for my $Port (keys %{$Port_Channel_Details}) { print "\nPort Channel $Port : \n"; for my $Interface_Port (keys %{$Interface_Details}) { next unless ($Port == $Interface_Port); print "$Interface_Port\n"; } }