Thanks for pointing that out. I think I knew it was there, but was turning my head out of laziness, i replaced all of the subroutines with a single new one that seems to get the job done:
sub execute {
my $i = shift;
my $mib = "$oid{$i}$tftpserver";
for my $host(@routers) {
chomp $host;
next if (($regex) and ($host !~ /$regex/));
$filename = "$host.cfg" if ($i eq "wrnet");
my $s = Net::SNMP->session( -hostname => $host,
-community => $community );
$s->set_request($mib, OCTET_STRING, $filename);
my $error = $s->error;
$s->set_request($oid{wrmem}, INTEGER, "1") if ($commit);
$s->close;
if ($error) {
print "\n$error\n\n";
} elsif ($i eq "wrnet") {
print "\nSuccessfully wrote config to tftpserver for $host.\n\n"
+;
} elsif ($i eq "confnet") {
print "\nSuccessfully sent config to $host.\n\n";
}
}
}
humbly -c