Solved

ISP Missing Modules: Can I reference locally?

Posted on 2004-10-08
13
176 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
  • 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
 

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now