Forum Moderators: coopster & phranque

Message Too Old, No Replies

File not found

         

jehoshua

8:50 pm on Dec 9, 2020 (gmt 0)

10+ Year Member Top Contributors Of The Month



The following Perl script to test sending emails ..

#!/usr/bin/perl
use strict;
use warnings;

# first, create your message
use Email::MIME;
my $message = Email::MIME->create(
header_str => [
From => 'you@example.com',
To => 'friend@example.com',
Subject => 'Happy birthday!',
],
attributes => {
encoding => 'quoted-printable',
charset => 'ISO-8859-1',
},
body_str => "Happy birthday to you!\n",
);

# send the message
use Email::Sender::Simple qw(sendmail);
sendmail($message);


If I test it locally, the message is
Can't locate Email/MIME.pm in @INC (you may need to install the Email::MIME module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.28.1 /usr/local/share/perl/5.28.1 /usr/lib/x86_64-linux-gnu/perl5/5.28 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.28 /usr/share/perl/5.28 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at testemail.pl line 6.
BEGIN failed--compilation aborted at testemail.pl line 6.


which makes sense. However if I test it on a website, Firefox simply says "Firefox can’t find the file at http://example.com/testemail.pl.

I have checked the web server and it has Perl installed (5.16.3) and the path is set to /usr/bin/perl

Am I to assume that on the web server, it is the same Perl modules that aren't installed, even though it appears that the actual Perl script file can't be found (when in fact the file is there, perms are 664) ?

phranque

10:09 pm on Dec 9, 2020 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Am I to assume that on the web server, it is the same Perl modules that aren't installed, even though it appears that the actual Perl script file can't be found (when in fact the file is there, perms are 664) ?

have you checked the apache web server error log file for clues?

jehoshua

10:33 pm on Dec 9, 2020 (gmt 0)

10+ Year Member Top Contributors Of The Month



have you checked the apache web server error log file for clues?


The error reporting is setup to log to a file. With PHP errors, it is doing that fine, but nothing written out for the Perl side of things ? Maybe the file should reside in the /cgi-bin path on the web server ?

phranque

12:23 am on Dec 10, 2020 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



but nothing written out for the Perl side of things ?

if you are running perl as cgi, error out goes to the web server error log file.

jehoshua

1:29 am on Dec 10, 2020 (gmt 0)

10+ Year Member Top Contributors Of The Month



I read up on file permissions and now have set the perms to 755, yet the same error occurs. This script

#!/usr/bin/perl
print "Content-type: text/plain\n\n";
print "testing...\n";


works fine but the other one doesn't, same error message. I cannot find the web server log file, and if a PHP error it gets logged to a file I can check. Yet nothing there. It is most likely failing on trying to include the module/library. I may read up on error reporting and see if $stdout can display something. Thanks for your help.

jehoshua

1:54 am on Dec 10, 2020 (gmt 0)

10+ Year Member Top Contributors Of The Month



I looked through some old Perl scripts and found error logging. This is how the top part of the original script looks now

#!/usr/bin/perl -w

BEGIN {
use CGI::Carp qw(carpout);
open(LOG, ">>/home/********/public_html/cgi-bin/errors-log") or
die("Unable to open errors-log: $!\n");
carpout(LOG);
}

use strict;
use warnings;


and of course the script failed, 500 error, however the error logging now informs me it was similar to when I tried the script locally

Can't locate Email/MIME.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /home/********/public_html/cgi-bin/testemail.pl line 14.
BEGIN failed--compilation aborted at /home/********/public_html/cgi-bin/testemail.pl line 14.


So the "file not found" was the browsers attempt to interpret a Perl module not able to be located.

not2easy

4:26 pm on Feb 5, 2021 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



This might be of interest, depending on various unrelated settings: https://metacpan.org/pod/distribution/CGI/lib/CGI.pod

It came up in another issue and apparently involved CPanel changes. It may or may not be related. (sorry, I don't do any perl coding) This
CGI::Carp qw
is the same on the other issue. Apparently
CGI.pm HAS BEEN REMOVED FROM THE PERL CORE
and I thought it might help here.

jehoshua

8:46 pm on Feb 5, 2021 (gmt 0)

10+ Year Member Top Contributors Of The Month



Thanks, it could be similar, the messages I had were related to Email/MIME.pm though.

It does seem that CGI is a pure Perl module, and replacing it is a lot of work, some discussions at [perlmonks.org...]

I used to use the
CGI::Carp
for error reporting and it does seem that these days there are alternate methods.

phranque

10:32 pm on Feb 5, 2021 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



It does seem that CGI is a pure Perl module, and replacing it is a lot of work,...

at the time the referenced discussion on perlmonks occurred, CGI.pm was a perl core module.
as of October 4, 2020:
CGI.pm HAS BEEN REMOVED FROM THE PERL CORE

see this: https://metacpan.org/pod/distribution/CGI/lib/CGI.pod#CGI.pm-HAS-BEEN-REMOVED-FROM-THE-PERL-CORE
If you upgrade to a new version of perl or if you rely on a system or vendor perl and get an updated version of perl through a system update, then you will have to install CGI.pm yourself with cpan/cpanm/a vendor package/manually.

(i would suggest reading the entire section)
in other words, CGI.pm doesn't have to be replaced to get your application working, it just needs to be a separately installed module once perl has been upgraded by your host.

i wouldn't necessarily recommend replacing CGI.pm on an existing application.

fyi this is some CPAN documentation on CGI alternatives [metacpan.org]


Thanks, it could be similar, the messages I had were related to Email/MIME.pm though.

it could be similar in the sense that if your host did a perl update perhaps you have to reinstall any non-standard modules you are using (such as Email/MIME)

see this for a list of standard modules:
https://perldoc.perl.org/modules#Standard-Modules

jehoshua

1:02 am on Feb 6, 2021 (gmt 0)

10+ Year Member Top Contributors Of The Month



see this: https://metacpan.org/pod/distribution/CGI/lib/CGI.pod#CGI.pm-HAS-BEEN-REMOVED-FROM-THE-PERL-CORE


Thanks, very handy document; there certainly is a lot there.

in other words, CGI.pm doesn't have to be replaced to get your application working, it just needs to be a separately installed module once perl has been upgraded by your host.

i wouldn't necessarily recommend replacing CGI.pm on an existing application.


In moving hosts about April last year, I did notice the /cgi-bin path was empty, whereas prior it contained at least 3 or 4 files. Just checked an old backup, yes it has 4 "cgi" files in it.

fyi this is some CPAN documentation on CGI alternatives [metacpan.org]


Thanks, handy reference.

it could be similar in the sense that if your host did a perl update perhaps you have to reinstall any non-standard modules you are using (such as Email/MIME)


I don't think there was any Perl at all included in the hosting. But back in Dec I asked and they added it, no fee. Also there was no Python either, same again, added it, no charge. The hosting company are very good.

see this for a list of standard modules:
https://perldoc.perl.org/modules#Standard-Modules


Thanks, I searched for "CGI", yep, gone now. It has the carious 'mail' modules I need though, thanks.

[edited by: phranque at 1:08 am (utc) on Feb 6, 2021]
[edit reason] unlinked urls [/edit]

phranque

1:04 am on Feb 6, 2021 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



as of October 4, 2020:

i read this date of the latest CPAN CGI.pm documentation [metacpan.org] and assumed that was when this removal was made.

in fact, CGI.pm was removed from the perl core in perl 5.22:
https://perldoc.perl.org/perl5220delta#Removed-Modules-and-Pragmata

perl 5.22 was released june 1, 2015:
[nntp.perl.org...]

It came up in another issue and apparently involved CPanel changes.

recent updates of hosting software can make old deprecations news.

[edited by: phranque at 1:11 am (utc) on Feb 6, 2021]

phranque

1:10 am on Feb 6, 2021 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



In moving hosts about April last year, I did notice the /cgi-bin path was empty, whereas prior it contained at least 3 or 4 files.

that's not relevant to the removal of CGI.pm from the perl core.

jehoshua

2:37 am on Feb 6, 2021 (gmt 0)

10+ Year Member Top Contributors Of The Month



in fact, CGI.pm was removed from the perl core in perl 5.22:
[perldoc.perl.org...]

perl 5.22 was released june 1, 2015:
[nntp.perl.org...]


I looked at the hosting, it is Perl version 5.16.3 , which was released in 2013. Seems I'd better ask to have it updated.

recent updates of hosting software can make old deprecations news.


Yes, true.

jehoshua

11:49 pm on Feb 6, 2021 (gmt 0)

10+ Year Member Top Contributors Of The Month



It seems the root issue with this is the hosting company have to allow my access to the compiler, as I need to install Perl modules to even run the small test script. Hopefully that will happen in a day or so. Thanks for your help.

phranque

1:50 am on Feb 7, 2021 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



the hosting company have to allow my access to the compiler, as I need to install Perl modules to even run the small test script

is this to install CGI.pm?

if so, you may want to pay attention to this note:
... the CGI::Fast module has been split into its own distribution, meaning you do not need access to a compiler to install CGI.pm

source: https://metacpan.org/pod/distribution/CGI/lib/CGI.pod#CGI.pm-HAS-BEEN-REMOVED-FROM-THE-PERL-CORE

jehoshua

3:25 am on Feb 7, 2021 (gmt 0)

10+ Year Member Top Contributors Of The Month



is this to install CGI.pm?


No, just
Email::MIME
and
Email::Sender::Simple
for now. I won't install CGI.pm

Thanks :)