Solved

Dropping nas session

Posted on 2009-05-18
2
241 Views
Last Modified: 2012-05-07
Hello i have script to drop NAS session.
but there is errors.
here is code.
it returns :
ERROR: Received noSuchName(2) error-status at error-index 1.
#! /usr//bin/perl
use strict;
use Net::SNMP;
my ($session, $error) = Net::SNMP->session(
-hostname  => '192.168.1.1',
-community => 'private',
-port      => 161
);
 
if (!defined($session)) {
    printf("ERROR: %s.\n", $error);
    exit 1;
}
 
my $indexOfConnection = '1.3.6.1.2.1.4.21.1.2.'."$ARGV[0]";
my $result = $session->get_request(
    -varbindlist => [$indexOfConnection]
);
 
if (!defined($result)) {
printf("ERROR: %s.\n", $session->error);
$session->close;
exit 1;
}
    print "index : $result->{$indexOfConnection}\n";
 
my $dropConnection = ".1.3.6.1.2.1.2.2.1.7.".$result->{$indexOfConnection};
print $dropConnection."\n";
 
 
my   $resultt = $session->set_request(
    -varbindlist => [($dropConnection, INTEGER, 2)],
);
 
if (!defined($resultt)) {
printf("ERROR: %s.\n", $session->error);
$session->close;
exit 1;
}
#    print "drop : $resultt->{$dropConnection}\n";
$session->close;
exit 0;

Open in new window

0
Comment
Question by:_Amanat_
2 Comments
 
LVL 11

Accepted Solution

by:
climbgunks earned 250 total points
ID: 24418756

first:  make your error messages different so you know what line they came from..or add that error to the message

but I'd guess you're not specifying the right version number to the session

add

-version => 2     #   version can be 1, 2, 3    I think 1 is the default, but that's old



0
 

Author Comment

by:_Amanat_
ID: 24419233
thanks.
it a wrong version
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Stuck in INIT/DROTHER 2 25
Random Terminal Server disconnections. 2 173
Interface VLAN dependencies 6 50
Upgrade firmware on Engenius BH-ENS202Wi-Fi router 5 39
Problem Description:   Couple of months ago we upgraded the ADSL line at our branch office from Home to Business line. The purpose of transforming the service to have static public IP’s. We were in need for public IP’s to publish our web resour…
Quality of Service (QoS) options are nearly endless when it comes to networks today. This article is merely one example of how it can be handled in a hub-n-spoke design using a 3-tier configuration.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question