Commit a6a8225d authored by Mac Newbold's avatar Mac Newbold
Browse files

Fixed errors when a vlan has no members.

parent 09a9e87b
...@@ -8,8 +8,6 @@ my $TBROOT = "@prefix@"; ...@@ -8,8 +8,6 @@ my $TBROOT = "@prefix@";
$ENV{'PATH'} = '@prefix@/sbin:@prefix@/bin:/bin'; $ENV{'PATH'} = '@prefix@/sbin:@prefix@/bin:/bin';
open(LIST,"snmpit -l |") || die ("savevlans: couldn't run snmpit: $!\n");
my $time = `date +20%y%m%d-%H.%M.%S`; my $time = `date +20%y%m%d-%H.%M.%S`;
chomp ($time); chomp ($time);
my $name = "$TBROOT/backup/vlans-$time"; my $name = "$TBROOT/backup/vlans-$time";
...@@ -22,13 +20,17 @@ use Fcntl; ...@@ -22,13 +20,17 @@ use Fcntl;
sysopen(OUT, $name, (O_WRONLY | O_EXCL | O_CREAT) ) || sysopen(OUT, $name, (O_WRONLY | O_EXCL | O_CREAT) ) ||
die ("savevlans: couldn't open '$name' for writing: $!\n"); die ("savevlans: couldn't open '$name' for writing: $!\n");
open(LIST,"snmpit -l |") || die ("savevlans: couldn't run snmpit: $!\n");
print OUT "START vlan\n"; print OUT "START vlan\n";
while(<LIST>) { while(<LIST>) {
chop; chop;
if (/(^ID)|(^--)|(^1 )/) { next; } if (/(^ID)|(^--)|(^1 )/) { next; }
s/[\t ]+/ /g; s/[\t ]+/ /g;
/(\d+)\s+(\S+)\s+(.*)/; /(\d+)\s+(\S+)\s+(.*)?/;
if ($2 ne "System") { if (!defined $3) { next; }
#print "split to $1, $2, $3\n";
if ($2 ne "default") {
(my $name, my @IDs) = ($2,split(" ",$3)); (my $name, my @IDs) = ($2,split(" ",$3));
print OUT "$name @IDs\n"; print OUT "$name @IDs\n";
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment