Unsolved
This post is more than 5 years old
7 Posts
0
8633
March 27th, 2009 09:00
perl api
hi folks,
i tried to use the perl API with the following example script:
----------------------------------------------------------------------------------
#!/usr/bin/perl
use InCharge::session;
use InCharge::object;
$session = InCharge::session->init( );
$device = "Router::myrouter.net";
$obj = $session->object( $device );
$vendor = $obj->{Vendor};
print $vendor . "\n”;
$session->detach( );
------------------------------------------------------------------------------------
but only get:
Can't locate InCharge/session.pm in @INC (@INC contains: /usr/lib64/perl5/5.8.5/x86_64-linux-thread-multi /usr/lib/perl5/5.8.5 /usr/lib64/perl5/site_perl/5.8.5/x8-multi /usr/lib64/perl5/site_perl/5.8.3/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.2/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.1/x86_ulti /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4 /usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2 /usr/lib/perl5/site_perl/5.8.1 /ur_perl/5.8.5/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.4/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.3/x86_64-linux-thread-multi //vendor_perl/5.8.1/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.0/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_p/usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl .) at perlapitest.pl line 2.
BEGIN failed--compilation aborted at perlapitest.pl line 2.
How can i install the API?
If anyone knows, thank u for the help.
Regards, Stephan
davemalhotra
3 Posts
0
March 27th, 2009 11:00
use sm_perl.
TCorcoran
53 Posts
1
March 31st, 2009 12:00
You have to add the appropriate SMARTS directory (e.g. /opt/InCharge7/SAM/smarts/perl/5.8.8/lib/InCharge/ if you are using PERL 5.8.8) to your @INC, or you have to copy the modules to your appropriate PERL site mod directory already listed in @INC.
Adding a directory to your @INC:
1. Add the directory to the PERL5LIB environment variable.
2. Add use lib 'directory'; in your Perl script.
- TC
stoechi
7 Posts
0
April 6th, 2009 08:00
Thanks for ur help,
but i still do sth wrong, in my script i put
use lib '/opt/InCharge72/SAM/smarts/perl/5.8.8/lib/InCharge';
use InCharge::object;
use InCharge::session;
and the environmental gets the necessary content:
[root@smarts1 sth]# export PERL5LIB=/opt/InCharge72/SAM/smarts/perl/5.8.8/lib/InCharge
as the output of PERL5LIB shows:
[root@smarts1 sth]# echo $PERL5LIB
/opt/InCharge72/SAM/smarts/perl/5.8.8/lib/InCharge
Starting the Script, i get:
Can't locate InCharge/object.pm in @INC (@INC contains: /opt/InCharge72/SAM/smarts/perl/5.8.8/lib/InCharge/ /opt/InCharge72/SAM/smarts/perl/5.8.8/lib/InCharge/5.8.5/x86_64-linux-thread-multi /opt/InCharge72/SAM/smarts/perl/5.8.8/lib/InCharge/5.8.5 /opt/InCharge72/SAM/smarts/perl/5.8.8/lib/InCharge/x86_64-linux-thread-multi /opt/InCharge72/SAM/smarts/perl/5.8.8/lib/InCharge/5.8.4 /opt/InCharge72/SAM/smarts/perl/5.8.8/lib/InCharge/5.8.3 /opt/InCharge72/SAM/smarts/perl/5.8.8/lib/InCharge/5.8.2 /opt/InCharge72/SAM/smarts/perl/5.8.8/lib/InCharge/5.8.1 /opt/InCharge72/SAM/smarts/perl/5.8.8/lib/InCharge/5.8.0 /opt/InCharge72/SAM/smarts/perl/5.8.8/lib/InCharge /usr/lib64/perl5/5.8.5/x86_64-linux-thread-multi /usr/lib/perl5/5.8.5 /usr/lib64/perl5/site_perl/5.8.5/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.4/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.3/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.2/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.1/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.0/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4 /usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2 /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.5/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.4/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.3/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.2/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.1/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.0/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4 /usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2 /usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl .) at perlapitest.pl line 3.
BEGIN failed--compilation aborted at perlapitest.pl line 3.
The files object.pm and session.pm are located in the folder /opt/InCharge72/SAM/smarts/perl/5.8.8/lib/InCharge
What the hell am i doing wrong? Thx for ur help..
Stephan
Hi, looks like i found the reason:
export PERL5LIB=/opt/InCharge72/SAM/smarts/perl/5.8.8/lib/InCharge
but now i get a new problem inside the module! :
syntax error at /opt/InCharge72/SAM/smarts/perl/5.8.8/lib/InCharge/session.pm line 942, near "|| ) "
Compilation failed in require at perlapitest.pl line 5.
BEGIN failed--compilation aborted at perlapitest.pl line 5.
Anyway, i think we solved the main problem! ;o)
Thx, Stephan
Nachricht geändert durch stoechi
ashv1
7 Posts
0
April 6th, 2009 12:00
not sure what is ur SAM version, in SAM 7.2.0.X you have to use sm_perl to initiate any connection to SAm using PERl.
additionally you need to search FLOWCONTROL in powerlink knowledge base to comment out some lines and modifying others in sessions.pm.
TCorcoran
53 Posts
0
May 11th, 2009 09:00
stoichi,
Have you gotten this working yet?
Can you post the output of the following 2 commands?
perl -e "print join(\"\n\", @INC);"
find / -name InCharge
That will help narrow it down.
- TC
stoechi
7 Posts
0
February 12th, 2010 02:00
Hi,
we got it working somehow with ur help, but forgot exactly what the reason was. Its too long ago.
Thats the output:
/usr/local/lib/perl5/5.8.8/x86_64-linux
/usr/local/lib/perl5/5.8.8
/usr/local/lib/perl5/site_perl/5.8.8/x86_64-linux
/usr/local/lib/perl5/site_perl/5.8.8
/usr/local/lib/perl5/site_perl
and
/usr/local/src/perl-5.8.8/lib/InCharge
/usr/local/lib/perl5/5.8.8/InCharge
find: /proc/15045/task: No such file or directory
find: /proc/15045/fd: No such file or directory
find: /proc/19700/task: No such file or directory
find: /proc/19700/fd: No such file or directory
find: /proc/20688/task: No such file or directory
find: /proc/20688/fd: No such file or directory
find: /proc/20689/task: No such file or directory
find: /proc/20689/fd: No such file or directory
/opt/InCharge70/NPM/smarts/perl/5.8.0/lib/InCharge
/opt/InCharge70/NPM/smarts/perl/5.6.1/lib/InCharge
/opt/InCharge70/NPM/smarts/local/perl/5.8.0/lib/InCharge
/opt/InCharge70/NPM/smarts/local/perl/5.6.1/lib/InCharge
/opt/InCharge70/IP/smarts/perl/5.8.0/lib/InCharge
/opt/InCharge70/IP/smarts/perl/5.6.1/lib/InCharge
/opt/InCharge70/IP/smarts/local/perl/5.8.0/lib/InCharge
/opt/InCharge70/IP/smarts/local/perl/5.6.1/lib/InCharge
/opt/InCharge72/SAM/smarts/perl/5.8.8/lib/InCharge
/opt/InCharge72/SAM/smarts/perl/5.8.0/lib/InCharge
/opt/InCharge72/SAM/smarts/perl/5.6.1/lib/InCharge
/opt/InCharge72/SAM/smarts/local/perl/5.8.8/lib/InCharge
/opt/InCharge72/SAM/smarts/local/perl/5.8.0/lib/InCharge
/opt/InCharge72/SAM/smarts/local/perl/5.6.1/lib/InCharge
/opt/InCharge72/SAM.Adapters/smarts/perl/5.8.8/lib/InCharge
/opt/InCharge72/SAM.Adapters/smarts/perl/5.8.0/lib/InCharge
/opt/InCharge72/SAM.Adapters/smarts/perl/5.6.1/lib/InCharge
/opt/InCharge72/SAM.Adapters/smarts/local/perl/5.8.8/lib/InCharge
/opt/InCharge72/SAM.Adapters/smarts/local/perl/5.8.0/lib/InCharge
/opt/InCharge72/SAM.Adapters/smarts/local/perl/5.6.1/lib/InCharge
/opt/InCharge71/MPLS/smarts/perl/5.8.0/lib/InCharge
/opt/InCharge71/MPLS/smarts/perl/5.6.1/lib/InCharge
/opt/InCharge71/MPLS/smarts/local/perl/5.8.0/lib/InCharge
/opt/InCharge71/MPLS/smarts/local/perl/5.6.1/lib/InCharge
/opt/InCharge8/SAM/smarts/perl/5.8.8/lib/InCharge
/opt/InCharge8/SAM/smarts/perl/5.8.0/lib/InCharge
/opt/InCharge8/SAM/smarts/perl/5.6.1/lib/InCharge
/opt/InCharge8/SAM/smarts/local/perl/5.8.8/lib/InCharge
/opt/InCharge8/SAM/smarts/local/perl/5.8.0/lib/InCharge
/opt/InCharge8/SAM/smarts/local/perl/5.6.1/lib/InCharge
/opt/InCharge8/CONSOLE/smarts/perl/5.8.8/lib/InCharge
/opt/InCharge8/CONSOLE/smarts/perl/5.8.0/lib/InCharge
/opt/InCharge8/CONSOLE/smarts/perl/5.6.1/lib/InCharge
/opt/InCharge8/CONSOLE/smarts/local/perl/5.8.8/lib/InCharge
/opt/InCharge8/CONSOLE/smarts/local/perl/5.8.0/lib/InCharge
/opt/InCharge8/CONSOLE/smarts/local/perl/5.6.1/lib/InCharge
/opt/InCharge8/NPM/smarts/perl/5.8.8/lib/InCharge
/opt/InCharge8/NPM/smarts/perl/5.8.0/lib/InCharge
/opt/InCharge8/NPM/smarts/perl/5.6.1/lib/InCharge
/opt/InCharge8/NPM/smarts/local/perl/5.8.8/lib/InCharge
/opt/InCharge8/NPM/smarts/local/perl/5.8.0/lib/InCharge
/opt/InCharge8/NPM/smarts/local/perl/5.6.1/lib/InCharge
/opt/InCharge8/IP/smarts/perl/5.8.8/InCharge
/opt/InCharge8/IP/smarts/perl/5.8.8/lib/InCharge
/opt/InCharge8/IP/smarts/local/perl/5.8.8/InCharge
/opt/InCharge8/MPLS/smarts/perl/5.8.8/lib/InCharge
/opt/InCharge8/MPLS/smarts/perl/5.8.0/lib/InCharge
/opt/InCharge8/MPLS/smarts/perl/5.6.1/lib/InCharge
/opt/InCharge8/MPLS/smarts/local/perl/5.8.8/lib/InCharge
/opt/InCharge8/MPLS/smarts/local/perl/5.8.0/lib/InCharge
/opt/InCharge8/MPLS/smarts/local/perl/5.6.1/lib/InCharge
So thanks for ur help!
Stephan