#!/usr/bin/perl use Net::SNMP; my $bah = "INTEGER"; snmpset("1.3.6.1.4.1.9.9.68.1.2.2.1.2.22","1.1.1.1","mystring",$bah,1); sub snmpset { my $oid = shift || die "No oid passed to snmpset\n"; my $host = shift || die "No host passed to snmpset\n"; my $string = shift || die "No community string passed to snmpset\n"; my $type = shift || die "No value type passed to snmpset\n"; my $value = shift || die "No value passed to snmpset\n"; print "Inside snmpset OID:$oid, HOST:$host, STRING:$string, TYPE:$type, VALUE:$value\n"; my ($session, $error) = Net::SNMP->session( -timeout => 5, -hostname => $host, -community => $string, -port => shift || 161 ); if (!defined($session)) { printf("ERROR ($oid $host $string): %s.\n", $error); #exit 1; return -1; } my $result = $session->set_request( -varbindlist => [$oid,$type,$value] ); if (!defined($result)) { printf("ERROR ($oid $host $string): %s.\n", $session->error); $session->close; return -1; } $session->close; return $result->{$oid}; }