Solved

ISP Missing Modules: Can I reference locally?

Posted on 2004-10-08
13
182 Views
Last Modified: 2010-03-05
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
Comment
Question by:darkyla
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 4
13 Comments
 
LVL 8

Expert Comment

by:inq123
ID: 12261944
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
 

Author Comment

by:darkyla
ID: 12262031
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
 
LVL 18

Accepted Solution

by:
kandura earned 150 total points
ID: 12262430
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
Independent Software Vendors: 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!

 

Author Comment

by:darkyla
ID: 12262569
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
 
LVL 8

Expert Comment

by:inq123
ID: 12262606
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
 
LVL 8

Expert Comment

by:inq123
ID: 12262640
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
 

Author Comment

by:darkyla
ID: 12262651
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
 
LVL 8

Expert Comment

by:inq123
ID: 12262685
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
 
LVL 18

Expert Comment

by:kandura
ID: 12262895
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
 
LVL 18

Expert Comment

by:kandura
ID: 12262923
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
 
LVL 18

Expert Comment

by:kandura
ID: 12262929
But my sample script would give you a nice error message as well.
0
 
LVL 8

Expert Comment

by:inq123
ID: 12262952
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
 

Author Comment

by:darkyla
ID: 12279781
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question