Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2794
  • Last Modified:

Can't locate loadable object for module SNMP in @INC

First of all i am new to perl, but i've had experience in other languages like c and vb. I am running win2k3 server, IIS 6.0, and ActivePerl 5.8.2. I am trying to execute this script located here: http://www.skendric.com/device/APC/ups-battery-status

The netops.pm is where i'm having problems. When i execute the script(ups-battery-status) i get this error:

Can't locate loadable object for module SNMP in @INC (@INC contains: C:\Perlib C
:/Perl/lib C:/Perl/site/lib .) at C:/Perl/lib/Netops.pm line 45
Compilation failed in require at C:/Perl/lib/Netops.pm line 45.
BEGIN failed--compilation aborted at C:/Perl/lib/Netops.pm line 45.
Compilation failed in require at C:\Perl\bin\ups-battery-status.pl line 78.
BEGIN failed--compilation aborted at C:\Perl\bin\ups-battery-status.pl line 78.

Also, whenever i see that i am missing a module or file of course i download it. Although how do i point the file to my windows directories?
For example, how do i make use Mail::Send; point to where put it, c:\perl\lib\mail\Send.pm  ?
Where should i be extracting the files needed for the scripts? in my c:\perl\lib directory?

Thanks
0
djsuperz
Asked:
djsuperz
1 Solution
 
FishMongerCommented:
What method do you use to "dounload" AND install the modules?  You should be using ppm.

ppm install Net-SNMP

That will download and install the module in the proper directories.

Or, you can use the CPAN module to install the modules.

perl -MCPAN -e "install Net::SNMP"

In eather case, you can enter the interactive shell then install.

ppm
install Net-SNMP

or
perl -MCPAN -e shell
install Net::SNMP
0
 
FishMongerCommented:
Looking over the code for the ups-battery-status module, I see that it's designed to run on a UNIX system.  You're probably going to need to modify it to run properly on Windows.
0
 
djsuperzAuthor Commented:
Being new at perl, will it run fine on Linux? What linux software do you recommend?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
FishMongerCommented:
It should run fine on Linux but you'll need to make sure you install all of the dependency modules.  For example, looking over some of the modules source code, you need both Net::SNMP and SNMP modules.  Since the last update to the SNMP module was in Feb 2001, it’s probably not being maintained any longer.   You’ll also need to make the proper adjustments in them to accommodate for any discrepancies in the paths used in their config section(s).

On another note, since most of these modules are not part of the base install of Perl, they are normally installed in c:\perl\site\lib\.  When installing via ppm or perl –MCPAN, the install path is handled automatically.  If you downloaded a tar or zip file then you may need to manually copy them to their proper locations.
0
 
mjcoyneCommented:
The @INC array works much like a PATH statement -- it tells Perl where to look for modules your script requires.  To avoid this error, you can put the module in one if the indicated directories (C:\Perlib, C:/Perl/lib, or C:/Perl/site/lib) or add your preferred directory to the @INC array:

BEGIN {
    unshift (@INC, "C:\\perl\\lib\\mail\\Send.pm");
}
0
 
mjcoyneCommented:
Looking at what I wrote, it'd be better to leave the actual name of the module off, and just provide the path:

BEGIN {
    unshift (@INC, "C:\\perl\\lib\\mail");
}

You can also achieve the same thing by the "use lib" method.  Just include at the top of your program this line before calling any modules:

use lib "C:\\perl\\lib\\mail";

Hope this helps!
0
 
FishMongerCommented:
It should be noted that the methods mjcoyne showed are for accessing modules that are installed outside of the default @INC directories.  The modules that we are working with here (SNMP and Mail::Send) are standard modules that should be installed via ppm or –MCPAN and will be found in @INC (C:/Perl/site/lib), if/when installed properly.

In this case it appears that the Mail::Send module was not found because djsuperz manually created the subdirectory and copied the module into it.  Normally this would not be a problem but remember case makes a difference to Perl.

C:/Perl/site/lib/mail  is not the same as C:/Perl/site/lib/Mail

Which means when you have

use Mail::Send;

Perl is looking for

   C:/Perl/site/lib/Mail/Send.pm  (or C:/Perl/lib/Mail/Send.pm)

Not

   C:/Perl/site/lib/mail/Send.pm (or C:/Perl/lib/mail/Send.pm)


*****
Additional note to mjcoyne;

It would be better/cleaner to use forward slashes and single quotes.

use lib 'C:/Perl/lib/Mail';
0
 
mjcoyneCommented:
I agree with all of FishMonger's points -- you should be installing things in their proper (read "expected") place.  However, you did ask " how do i make use Mail::Send; point to where [I] put it, c:\perl\lib\mail\Send.pm?", so I answered that...  Also, if you're were writing a limited use or special purpose module of your own, you might want to put it somewhere non-standard; if so this is how you do it...

>It would be better/cleaner to use forward slashes and single quotes.

Also agree completely -- force of a (bad) habit of mine...:).

0
 
jmcgOwnerCommented:
One more point of clarification:

When you say

use lib 'C:/Perl/lib/Mail';

use Mail::Send;

the interpreter is going to be looking in the wrong place. In looking for the module, the namespace qualifiers (the part before the ::) become part of the path for the filename, so the file -- if it were to be found -- would have to be

C:/Perl/lib/Mail/Mail/Send.pm

because one Mail comes from the INC entry and another is supplied as part of the module name. You really should only have the names of top-level library directories in @INC so that really should have been:

use lib 'C:/Perl/lib';

0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now