Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modules on A Hosted Server 1

Status
Not open for further replies.

audiopro

Programmer
Apr 1, 2004
3,165
GB
I am working on a script for a client and their ISP will not install a particular module I require.
Do all modules have to be installed in the root of the server or is it possible to call them within my client's CGI-BIN?

Keith
 
I suggest checking the @INC array on the server to see in what directories will be looked for modules.
 
@INC returns the following.
Code:
/usr/local/lib/perl5/site_perl/5.005/i386-freebsd
/usr/local/lib/perl5/site_perl/5.005
.
/usr/libdata/perl/5.00503/mach
/usr/libdata/perl/5.00503
That would appear to be outside my accessible area.

Keith
 
You should be able to add the module lib to your scripts and reference the module location from within your websites alloted directory structure.

Code:
#!/usr/bin/perl

uer lib '/usr/username/perl_modules/moduledir/';
. . .

- George
 
perldiver was suggested a while ago, and seems to do the business, might be worth a shot.

Also, suggest to your client, that their ISP needs a good reason not to install a particular module, if they wish to remain current. You can install modules locally using the use lib directive, might also be worth a shot

--Paul

Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
The '.' in the @INC array represents the current directory (e.g. the directory of your script). I assume you can easily place modules in there. (e.g. /path/script.pl and /path/IO/Socket.pm etc). If this is not what you want, 'use lib' like everyone else suggested :p
 
Thanks for the advice folks.
I have been using PERL for a number of years but have never needed to install any modules, maybe now is the time to start.
I will have a google for some relevant info, posibly on cpan, unless you can suggest an idiot's guide to module installation.

Keith
 
All the info I have found. deals with installing from the command line.
Could someone give me some pointers to installing modules onto a remote server
Thanks

Keith
 
You'll need access to the command line to invoke cpan interactively, though you could submit scripts to the webserver to do it for you if the webuser has the right access (and this would be a bad thing :-(), the same is true if you wish to run a script to unpack, complile and make modules

Usually, you call your webhost, and tell them you either want/need command line access to your account on the server, preferably over SSH, or you can install modules under the cgi-bin directory with use lib

documents the norm in your situation I'm afraid, but it is possible

Chapter 31 of the camel explains it in some detail.

If you come across a decent resource, please post it back here, this one comes up all the time ;-)

Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Hi,

Not sure if this is any use, but here is how we invoke installation of modules;

perl -MCPAN -e 'install Module::Name'

Hope that helps.

Cheers

Andy
 
Now this is a tale of woe that I've fully experienced. My hosting wouldn't give me shell access and wouldn't install additional modules for me, both due to "security". Ignoring their reasoning I grabbed and extracted tarballs of sources on my local windows machine, uploaded them and tried to run the standard perl Makefile.PL/make/make install routine. Well, almost worked. I could run make (the command, not the step), but the hosting service blocked access to gcc. It's shared hosting, and compiling takes lots of CPU time, so I guess I might be able to see this ...

Next possibility was to compile them on my local linux box. Both it and the target server were x86, no problem, right? I run debian with a 2.6 kernel and perl 5.8, whereas the server ran redhat 7 with a 2.4 kernel and perl 5.6. No, binaries were not compatible.

Last, armed with the server specs, I searched the internet for rpm's of the modules I needed that were as close as I could get to the versions the host ran. I couldn't match the exact redhat version, but I could always find something in the same 7.x chain. I extracted the rpms for all the modules I needed and uploaded them, used lib and was well on my way.

The only last wrench in it all was one of my pre-req's was a Date:: module that had an optional XS component. Docs say it was supposed to work without it, albeit slower. Well, it refused to run without it, so I found another rpm and everything's been working just peachy for six months now.

The moral of the story: you can nearly always get stuff done, even with stubborn hosting, it just takes a little (lot) more effort.

- Andrew
Text::Highlight - A language-neutral syntax highlighting module in Perl
also on SourceForge including demo
 
Thanks Andrew but that is way beyond my tech ability.
I know work rounds are possible but I have not got the time or patience to hit it head on, I leave these tasks to the 'C' crowd who relish this kind of thing.
The module I require is image::magick.
I have a client who uploads over 40 jpegs each week and then creates a HTML page of thumbnails from them all.
He complains it takes too long and has asked me if there is a quicker way.
This is the sort of thing which PERL is made for but my ability falls short. I have done work on bitmaps and can manipulate them till the cows come home but compressed files are harder to deal with. I have a several totally unrelated apps. in the pipeline, which would benefit from image manipulation so I have more than a passing interest. Googling around for details on jpeg format and conversion returns very little in the way of information.



Keith
 
if you are going to use the "use lib" pragma you don't "install" modules. You upload them as Andrew did and hope for the best. In my experience the lib pragma works good for simple modules, and some not so simple, but modules that have tons of dependencies or need to be installed with various options, probably will not work unless you are tenacious and refuse to give up, and even then may not work.

Nix boxes come with a jpeg utility djpeg/cjpeg you can google around for details. Good for jpegs but not much else.
 
What about writing a windows script for you r clients machine where you do have access, and have the script upload using LWP, or Net::FTP/SCP.

That way you have the best of both worlds ...
--Paul
 
FAQ #5 in the CPAN POD explains how to use cpan to install modules without being root by putting them in a different directory. Using this method, you still formally "install" modules, and have to "use lib" to include them. Since the method just sets Makefile.PL args, you can use the same thing if manually building and installing from .tar.gz sources.

Instead of Image::Magick, GD may be easier to install. It's still non-standard and has XS components, though. It has a reasonably rich feature set, I use it to resize and pad the random images catalog vendors give me. I'd love to use Gimp::Fu, but it doesn't seem at all designed with Win32 in mind.

Finding and unpacking appropriate .rpm's wasn't all that difficult. Find out what CPU architecture (x86/P4), operating system & version (RedHat Linux 7.4), and Perl version (5.6.0) your hosting uses. We can try and help you from there.

- Andrew
Text::Highlight - A language-neutral syntax highlighting module in Perl
also on SourceForge including demo
 
perl -V on the command line (case is important) ;-)

Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Command line?

All may not be lost with one of the ISP's.
They have informed me that Image::Magick is installed on their server, that's the good news. The bad news is that I cannot use it at the moment.
This is getting interesting now.

Keith
 
It's there but you can't use it? How's that work?

Most things that get suggested to do on the command line you can do just by uploading a dummy perl script with a system call, something like:
Code:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print `perl -V`;

- Andrew
Text::Highlight - A language-neutral syntax highlighting module in Perl
also on SourceForge including demo
 
That's the question I have just asked them.
Tried this but it gives me a config error when the 'use' line is included.
Code:
#!/bin/perl  
print "Content-type: text/html\n\n";
use Image::Magick;
print "Script ok<br>";
I always thought the command line was an inaccessable thing but running your sample code told me all kinds of things about PERL. Not sure what most of it means apart from the version number but here is what I think you are after.
Code:
Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration: Platform: osname=linux, osvers=2.6.6-1.435.2.3, archname=i386-linux-thread-multi uname='linux bob 2.6.6-1.435.2.3 #1 thu jul 1 08:25:28 edt 2004 i686 athlon i386 gnulinux


Keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top