Hi,
I am absolutely new to perl and for a specific reqmt I am running the following script:
- #!/usr/bin/perl
-
use warnings;
-
use lib '/opt/InCharge65/IP/smarts/perl/5.6.1/lib';
-
use InCharge::session;
-
$session = InCharge::session->init();
-
$session = InCharge::session->new( "INCHARGE" );
-
$session = InCharge::session->new(
-
broker=>"10.213.31.209:426",
-
domain=>"IPVPN-APM2",
-
username=>"admin",
-
password=>"changeme",
-
traceServer => 1
-
);
-
$object = $session->create( "Router::crossroads" );
-
$session->detach( );
The errors that I am getting are:
Name "main::object" used only once: possible typo at ./routerpl.pl line 14.
[8] Cant find domain 'INCHARGE' in broker 'localhost:426', stopped at ./routerpl.pl line 5
PLEASE HELP SOON
Thanks
Gaurav
The first warning is about your line
- $object = $session->create( "Router::crossroads" );
because this is the only place in your script where "$object" is used. When warnings are turned on, perl alerts you to situations like this because there is usually a mistake involved when you create a variable but don't use it again.
The second problem sent me to Google to find out about InCharge, which appears to have something to do with Cisco routers. Is the address 10.213.31.209 the computer that is running this script or is it the router? Do you know which it is supposed to be?
Lines 5, 6 and 7 look very suspicious to me. 6 and 7 BOTH appear to be creating new sessions (each called $session). I don't know anything about the Cisco InCharge module, but that seems wrong. I also suspect that if you need both "->new" and "->init" that line 5 would more likely follow 6 or 7 than precede. Line 14 looks suspicious too.
I just opened up the
InCharge Perl Reference Guide and on page 27 (by the numbering at the bottom of the page) I see something resembling your code. It looks like you took ALL of the alternative ways of trying to open a session and plopped them all into a single script. Use only one of the forms.
I understand that you say you are new to perl, but I'm afraid I can't just hand you a working script because I don't have access to a Cisco InCharge router to experiment with. It also appears that the script as it is does not actually
do anything with the router. It just opens a session and then closes it. I would guess that you might start with something more like this:
- #!/usr/bin/perl
-
use warnings;
-
use strict;
-
use lib '/opt/InCharge65/IP/smarts/perl/5.6.1/lib';
-
use InCharge::session;
-
my $session = InCharge::session->new(
-
broker=>"10.213.31.209:426",
-
domain=>"IPVPN-APM2",
-
username=>"admin",
-
password=>"changeme",
-
traceServer => 1
-
);
-
# do something with the router ???
-
$session->detach( );
where the comment "# do something with the router" indicates where you would actually do whatever work your script is intended to do in the way of setting your router.
Good Luck,
Paul