Go Premium for a chance to win a PS4. Enter to Win

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

ISP Missing Modules: Can I reference locally?

Hello -

Let me preface with the disclaimer that I'm a CGI script end-user. I don't know how to write in Perl.

Earthlink is my ISP, and they are missing the LWP, LWP::UserAgent, and LWP::Simple modules that I apparently need for several scripts. I've called them and they refuse to install the modules for me (%@#$%).... some drivel about "optimal configuration for all end users".

Can I get around this? Can I somehow load these libraries locally and call them in the beginning of the script somehow?

Help! Thanks!

S.
0
darkyla
Asked:
darkyla
  • 5
  • 4
  • 4
1 Solution
 
inq123Commented:
Hi darkyla,

Most of the perl modules can be used locally as long as you set lib path correctly using either environment variables or "use lib" statement.  I'm not totally sure about these ones since I installed them in my default system directory, but I think it'd work.

Cheers!
0
 
darkylaAuthor Commented:
Great! Sounds promising.... but how do I do it?  I'm on a UNIX server, if that makes a difference in terms of the syntax for calling the library. Do I need to use an absolute path or a relative path?  What's the syntax?

Thanks!
0
 
kanduraCommented:
Do you have shell access to that server?

If not, then
- place your libraries in a subdirectory lib/ somewhere above your cgi-bin directory
- make sure that you place them in correctly named directories, e.g. LWP::Simple should be in
    lib/LWP/Simple.pm
- add the following line to the top of your script.
    use lib '/my/full/path/to/lib';

That's all there's to it, provided these modules are pure perl, and have no other unmet dependencies.
0
Industry Leaders: 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!

 
darkylaAuthor Commented:
I'm changing the point value on the question, since in my ignorance I now realize there are more questions related to this.  :)

I've installed a local copy of the core Windows distribution of Perl from CPAN.  This has the LWP modules I need, but now I'm not sure how to proceed. Do I copy the appropriate .pm files to  a directory in my cgi bin and reference their location in the script? Do I need to put more than those two or three files up to make the libraries function?

Thanks...
0
 
inq123Commented:
I would suggest putting lib under your cgi-bin directory because relative path makes it easy to migrate from server to server (you can even test it locally before moving to your server), also saves some trouble finding out full path.

So I would put a directory myLib under cgi-bin directory where your perl CGI is located.  Then in the perl script use
use lib 'myLib';
Of course as I said earlier you need to keep directory structure, in my example it'd be:
cgi-bin/myLib/LWP/Simple.pm

Just use your FTP client to upload the directories and files there.
0
 
inq123Commented:
Check the readme for LWP, LWP::Simple, etc.  They'd tell you dependencies.  If there's no dependency on other modules, no autoload, then yes, you can simply just copy the windows perl modules over to your web server's cgi-bin and reference them as I described above.
0
 
darkylaAuthor Commented:
How do I know if my modules are pure Perl?  And...

Do I need to use the absolute path (e.g. www/user/s4/dwiresourcecenter/webdocs/lib/LWP) or the relative path (e.g. ../lib/LWP).  

Kandura, if I understood you correctly, I'm only putting the Simple.pm file (and the other appropriate .pm files)  into the library directory, and nothing else?
0
 
inq123Commented:
no, he's just making an example.  You do need to put everything that's needed there.  As I said, check readme.

It's always pure perl (well, almost always) unless it calls autoload function, which uses platform dependent binaries, which means trouble.
0
 
kanduraCommented:
You can try using a relative path, and put your 'lib' directory in the cgi-bin dir, but I have dealt with several setups where the current working directory of my scripts was not the cgi-bin directory. I prefer to use absolute paths just to avoid problems.

You will have to upload the entire LWP directory.
And most likely you'll run into other dependencies, as LWP::UserAgent depends on e.g. HTTP::Request.

Just create a simple script to see if you've got everything:

    #!/usr/bin/perl
    #
    use CGI;
    use CGI::Carp qw/fatalsToBrowser/;
   
   
    my $q = CGI->new();
    print $q->header();
    eval {
            require LWP::Simple;
    };
    print  $q->pre("$@") if $@;
0
 
kanduraCommented:
To see if a module is not purely written in perl, you could check the perl/site/lib/auto directory of your local installation. If there's anything in there other than a file named .packlist, such as dll's, then you can be sure it's *not* a pure perl module.
0
 
kanduraCommented:
But my sample script would give you a nice error message as well.
0
 
inq123Commented:
kandura,

I agree that sometimes CWD on some servers are not cgi-bin but a level above.  In those cases absolute path is better.
0
 
darkylaAuthor Commented:
Y'all are brillant.  After some initial struggles figuring out how to build Perl modules correctly, it all works like a charm.  Thank you SO much! A whole new world has opened up...
0

Featured Post

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!

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