Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.05 KB | None | 0 0
  1. #!c:/perl/bin/perl.exe
  2.  
  3. my @interface=();
  4. my $isInterface=0;
  5. my $currentInterface="";
  6. my $currentType="";
  7. my $currentSlot="";
  8. my $currentPort="";
  9. my @Config=();
  10.  
  11. open (FILE, "hub1.conf");
  12. while (<FILE>)
  13. {
  14.     chomp;
  15.     if ($isInterface==1)
  16.     {  
  17.         if (/!/)
  18.         {
  19.             $interface[$currentSlot][$currentPort]=\@$currentInterface;
  20.             # $isInterface = 0;
  21.             # $currentInterface="";
  22.             # $currentType="";
  23.             # $currentSlot="";
  24.             # $currentPort="";
  25.             next;
  26.         }
  27.         else
  28.         {
  29.             #print "$currentInterface\n";
  30.             push @$currentInterface, $_;
  31.             next;
  32.         }
  33.     }
  34.    
  35.     if (/interface (.*)(\d+)\/(\d+)/)
  36.     {
  37.         $currentType = $1;
  38.         $currentSlot = $2;
  39.         $currentPort = $3;
  40.         $currentInterface = "$1$2/$3";
  41.         $isInterface = 1;
  42.         push @$currentInterface, "interface $currentInterface";
  43.     }
  44. }
  45. print "Interface is $currentInterface\n";
  46.  
  47. for $i ( 0 .. $#interface ) {
  48.     for $j (0 .. $#{$interface[$i]}) {
  49.         foreach $port ($interface[$i][$j])
  50.         {
  51.             foreach $line (@$port)
  52.             {
  53.                 if ($line=~/Gigabit/)
  54.                 {
  55.                     print "$line\n";
  56.                 }
  57.             }
  58.         }
  59.  
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement