Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Modules on a Unix server

by Anonymous Monk
on May 13, 2002 at 18:57 UTC ( [id://166245]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Please advise how I can find out where the Perl modules are located our Solaris 7 server? The System managers dont know where they are so I am going to try and find them myself. I have written all my Perl scripts with:
#!/usr/local/bin/perl
But now I want to start using modules such as:
use LWP::Simple; use Mail::Mailer;
The paths I have tried dont work:
#!/usr/bin/perl #!/usr/local/bin/perl
No luck here. I need to find where this server stores the modules so I can use the correct "#!shebang" notation.

Here are my error messages:
Can't locate LWP/Simple.pm in @INC (@INC contains: /usr/local/lib/perl +5/5.00502/ sun4-solaris-thread /usr/local/lib/perl5/5.00502 /usr/local/lib/perl5/ +site_perl/ 5.005/sun4-solaris-thread /usr/local/lib/perl5/site_perl/5.005 .) at w +ebCh.pl li ne 2. BEGIN failed--compilation aborted at webCh.pl line 2.

Replies are listed 'Best First'.
Re: Modules on a Unix server
by seattlejohn (Deacon) on May 13, 2002 at 19:12 UTC
    The shebang line tells the shell what program (Perl) to use to execute the contents of the file, but modules may live in a different directory. Once you find that directory, you can tell Perl to look for modules in it using the use lib statement:

    use lib '/path/to/modules/';

    (Do this before any of your other use statements.) You could also directly manipulate the @INC array, which tells Perl where to look for modules, but I personally consider the use lib syntax to be cleaner and more self-documenting.

    As for finding the module directory in the first place: You can probably use something like find -iname strict.pm. (Someone who's more of a Unix guru than I may have a better suggestion). You'll also need to be sure that the modules you intend to use are actually installed on your server, and download them if not. If your admins won't put these into a convenient directory you can always just create your own local module directory and use lib it.

      Please advise what I am doing wrong. I was given an area where we store our modules and it still has problems.
      use lib '/export/home/jones/perl/lib/perl5/site_perl/LWP/Simple.pm';


      Output message from my vir.pl script:
      vir.pl[6]: use: not found vir.pl[8]: =: not found vir.pl[13]: syntax error at line 13 : `(' unexpected


      My script does work on my NT but this module problem on Unix is another issue. Please advise if I am using the lib correctly?
        From the output you supplied, it sounds as if the initial shebang line is not correctly executing the Perl interpreter in the first place. Are you sure that line is correct in your script? You might try a really simple test program to see:

        #!/path/to/perl print "Hello, world";

        If you've got the shebang right, this should just output Hello, world when you execute it.

        As for use lib, what you probably really want to do is this:

        use lib '/export/home/jones/perl/lib/perl5/site_perl/'; use LWP::Simple;

        The first line basically says "when I write use Something, make sure you look in /export/home/jones/perl/lib/perl5/site_perl/ to find Something.pm."

        The second line actually uses the LWP::Simple module (appending lwp/Simple.pm to the path specified by use lib).

Re: Modules on a Unix server
by Speedy (Monk) on May 13, 2002 at 20:05 UTC
    Rather than your path being wrong, it may be that the LWP module has not been installed on your particular Solaris server.

    /usr/local/lib/perl5/site_perl/ is the default location for Perl modules on a staging Solaris server I use. This I found by using telnet and typing 'perl -V' for compile and path information.

    On this particular system by poking around I find the path /usr/local/lib/perl5/site_perl/5.6.0/LWP which, among other modules, contains Simple.pm.

    In several cases I have had to ask the tech support people on these particular C&W Solaris systems to install new modules from CPAN, which they in general have been very helpful in doing.

    Depending on your setup, if the system administrator will not intall the module in a central Perl library, you may be able to install it in one of the local directories in your web directories.

    Live in the moment
Re: Modules on a Unix server
by TStanley (Canon) on May 13, 2002 at 19:19 UTC
    The @INC array is an internal array to perl that contains the paths to any installed modules, and as a rule, the modules are located in those directories, so the actual perl executable would be somewhere above those. Also, you might want to check to see if LWP::Simple is installed on your system.


    UPDATE: seattlejohn has a better answer than mine

    TStanley
    --------
    Never underestimate the power of very stupid people in large groups -- Anonymous
Re: Modules on a Unix server
by BazB (Priest) on May 13, 2002 at 19:20 UTC
    perl -e 'print join "\n", @INC';
Re: Modules on a Unix server
by mephit (Scribe) on May 14, 2002 at 03:12 UTC
    Well, it looks like determining @INC isn't the problem. There's a script on CPAN called Inside that works for me. It says what modules are installed on your system, and where. Then again, I have my own Linux machine, so I'm not sure if it'd run correctly in your case (it may need special permissions to recurse all directories on the machine). Just to make sure, I'd point your sysadmins at that script, and ask them to run it. Never know what they might accuse you of if you run it yourself. If all else fails, you can just download them and install them into your personal directory *shrug* That's my suggestion, anyway. HTH.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://166245]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-06-20 09:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.