I started
this thread with very little knowledge of
net::snmp. I got some very good feedback and started working on a script that tries to use snmp to issue a 'copy run tftp' on a cisco router.
The script I am toying with is:
#!/usr/bin/perl -w
use strict;
use Net::SNMP;
my $router = "10.8.10.133";
my $community = "secretstring";
my $tftpdir = "/company/configs/";
my $tftpserver = "10.15.145.15";
my $oid = ".1.3.6.1.4.1.9.2.1.55.";
$oid = "$oid$tftpserver";
my $s; my $e;
($s, $e) = Net::SNMP->session( -hostname => $router -community => $com
+munity );
my @param = qw($oid OCTET_STRING "host.cfg");
$s->set_request(@param);
$s->close;
When I run this code, I receive the following errors:
Argument "community" isn't numeric in subtraction (-) at ./tftp.pl lin
+e 14.
Argument "57.8.10.133" isn't numeric in subtraction (-) at ./tftp.pl l
+ine 14.
Odd number of elements in hash assignment at
/usr/lib/perl5/site_perl/5.6.0/Net/SNMP.pm line 196.
Can't call method "set_request" on an undefined value at ./tftp.pl lin
+e 20.
I am thinking that I am putting an incorrect ASN.1 value in my @param, but I am not sure. The errors I am seeing seem to imply that they are expecting a numeric value.
Can anyone comment on the right path to correct this?
humbly -c
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.