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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Install a module on a remote nix server 1

Status
Not open for further replies.

audiopro

Programmer
Apr 1, 2004
3,165
GB
The remote server I use for testing has the MIME::lite module installed already and I was over the moon when, with the help of you TT folks, I got his SMTP email working.

Then I hit a snag, my client is on a different ISP and MIME::lite is not installed. I have been looking round cpan for some instructions on how to install a module on a remote server. The docs say it is a stand alone module so I assume it can be installed within my web space and then called as required.
I see a tar.gz file and a makefile.pl but I am unsure what to do with them. Could someone point me to a good article, hopefully not written in tek speak, where I could learn how do do the install.


Keith
 
You can accomplish this on UNIX using SSH.
Code:
ssh [i]<user>[/i]@[i]<hostname>[/i] "perl -MCPAN -e 'install MIME::Lite'"

M. Brooks
 
The user account on the remote server must have the proper permission to do so. Since the package is MIME::Lite, you will not have to compile.

Just move the directory MIME-Lite-x.x.x/lib/MIME to be local to your application and use the use lib pragma.

M. Brooks
 
You don't need to install the module. Create a folder on the remote site:

MIME/Lite

put the MIME::Lite code in that folder. Name the file "Lite.pm"

use the "lib" pragma to add the path to that folder to @INC:

Code:
use lib qw('path/to/MIME/Lite');

You can likewise add all the other modules MIME::Lite likes to use in a same manner. See the MIME::Lite documentation or source code for a list of those modules.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
I am feeling a bit numb here.
I think I have followed your instructions but as I can't get it to work I need to calrify some things.

My test script is in the cgi-bin - 'test.cgi'
I have created a sub folder 'mime', within that a sub folder called 'lite' and put the 'lite.pm' file there.
Does it need to be nested to 2 levels or could I just use the 'mime' folder?
What permissions do the folders need?
What permissions does the lite.pm file need.
My FTP software is set to force lower case, is this a problem providing I use the same case in the call?
This is the first part of my test script
I have put print statements in to check on progress, the function does not return.

Code:
use lib qw('mime/lite');
[red]use lite;{/red] do I need this?
print "1";

my $msg = MIME::lite->new(
	From =>'admin.mysite.com',
	To =>'targetemail',
	Subject =>'Welcome to the website',
	Type =>'multipart/related'
);

print "2";
I am sure it is straight forward once it works but with so many possible errors, I need a bit of guidance.

and in the lite.pm 'new' function, what does this do?
Code:
   return ( @_ ? $self->build(@_) : $self );


Keith
 
Remember, case SeNsItIvE.
Name the folder all upper-case: "MIME"
And the module: "Lite.pm"

Then use MIME::Lite like you would on any other server where it is installed.

Code:
use lib qw('cgi-bin/MIME/Lite');
use MIME::Lite;

or actually I think it should be:

Code:
use lib qw('cgi-bin/MIME');
use MIME::Lite;


try both and see which works.




------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Sorry to be a pain but I am still having trouble with this.
Sounds like a good subject for an FAQ.
The initial call to 'new' is not being completed, it appears to be falling down on the final line of sub new.

Code:
[red] from my test script[/red]
use lib qw('MIME');
print "2";
use MIME::Lite;
print "3";

my $msg = MIME::Lite->new(
From =>'me@home.com',
To =>'me@away.com',
Subject =>'Test Subject',
Type =>'multipart/related'
);
print "4";
Code:
[red] from MIME::Lite[/red]
sub new {
    my $class = shift;

    ### Create basic object:
    my $self = { Attrs    => {},    ### MIME attributes
                 SubAttrs => {},    ### MIME sub-attributes
                 Header   => [],    ### explicit message headers
                 Parts    => [],    ### array of parts
    };
    bless $self, $class;

    ### Build, if needed:
[blue]What does this line actually do?[/blue]
    return ( @_ ? $self->build(@_) : $self );
}
This prints 2 and 3 but not 4.
It does this with and without the 'lib' call.
Change
Code:
use MIME::Lite;
to
Code:
use MIME::L[red]u[/red]te;
gives a server error as expected so my asumption is that the module is being called.

Replacing
Code:
    return ( @_ ? $self->build(@_) : $self );
with
Code:
    return ( @_ );
returns the number 8 to $msg and prints 234.
Can you make any sense of this and more importatly, where I am going wrong.




Keith
 
You should not be messing around with any of the actual code in the Lite.pm module. The code you asked "what does it do" is returning the object back to the calling script. There is no need for you to edit anything in the Lite.pm module.

My code had a bit of an error, sorry, the syntax should be:

Code:
use lib qw(MIME);

no quotes around the list arguments, thats what 'qw' does. I think that will get it working properly.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Changed the lib to your suggestion but still nothing.
I edited the module in order to get a response from it. I figured that this would confirm that the module was being called.
What is the correct way to confirm a module is being called when it returns nothing?

My test script works ok on another server where the MIME::Lite module is installed. Are there different versions of the module?

Keith
 
1. Create a directory in your cgi-bin called lib.

2. Please the MIME directory in this directory.

3. Add the following lines in your perl script.
Code:
use lib qw( ./lib );
use MIME::Lite;
This should work if done correctly.

M. Brooks
 
Changed the lib to your suggestion but still nothing.

Works for me. Not sure why you're encountering difficulties. If you want to check success of the "new" method you can do this:

my $msg = MIME::Lite->new(
From =>'me@home.com',
To =>'me@away.com',
Subject =>'Test Subject',
Type =>'multipart/related'
) or die "$!";

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Kevin
This is the whole script but only prints 1 and 2.
Looks like something in the script is just halting it.
Code:
#!/usr/bin/perl

print "Content-type: text/html\n\n";	# prepare for HTML output

use strict;
print "1";
use lib qw(MIME);

use MIME::Lite;

print "2";

my $msg = MIME::Lite->new(
From =>'me@home.com <mailto:me@home.com>',
To =>'me@away.com <mailto:me@away.com>',
Subject =>'Test Subject',
Type =>'multipart/related'
) or die "$!"; 
print "3";
M. Brooks
I get the same response from your method too.

As a test, I changed the name of 'Lite.pm' and, in both cases, I got a server error as expected. I assume the module is being called but not returning anything.
Could it be permissions or some settings on the remote server?

Keith
 
Did you using the original unedited Lite.pm module or are you still using a version you edited? Check the server error logs also.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Hi Kevin
The file I am currently using is the original unedited version.
I was always taught to simplify, a stubborn to mend faulty program, as much as possible in order to isolate the cause.
I originally made a new module out of the 'new' sub routine in order to test the functionality and it still returned nothing, I am not sure why this approach was wrong as it seemed logical but I was not sure how to proceed. The ISP do not provide script assistance although I suspect it is a directory issue. I am now looking at permissions as a possible cause.
What should I set permissions of:-
MIME directory?
Lite.pm module?


Keith
 
Normal running of the script does not throw an error, it just locks up and reports nothing to the error log.
Changing the name of the module in the use statement ie. use MIME::lotty;
Gives me the expected
Code:
Premature end of script headers
error.
What else can I try?

Keith
 
I would think 700 would be OK but try 755 if you must.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
After much reading and a crash course in SSH it turns out that MIME::Lite calls other modules which were not installed.
I added the additional modules but hit a wall at the following command.
Code:
require Email::Date;
$self->add( "date", Email::Date::format_date() );
This reported an error as
Code:
can't locate loadable object for module Time::Piece
I know someone is going to shout at me but I edited a copy of the module to force a text date to be returned.
Code:
$self->add( "date", "Saturday 22nd. September 2007 20:11:34" );
and the MIME::Lite module returned th correct values.
I do not understand the syntax in Time::piece so it is study time again.




Keith
 
MIME::Lite should work without any other modules. It does use three or four other modules for various tasks, but MIME::Lite will run without them being installed. If you want to use the functionality of those other modeuls then of course you have to install them, but you can use the "lib" pragma to also include those modules in @INC.

If the datestamp is what is hanging you up read the MIME::Lite documentation, I'm pretty sure it's covered.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top