Guten Morgen,
I am implementing a script that my client wants on their website. Within
the script there are several "require" statements. Any time one of these
"require" statements is executed, the script terminates.
Any ideas how I might solve this problem?
Cheers! 15 6034
Michael wrote: I am implementing a script that my client wants on their website. Within the script there are several "require" statements. Any time one of these "require" statements is executed, the script terminates.
Any ideas how I might solve this problem?
How about installing the modules that it tries to require? Just a thought.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
On Thu, 18 Mar 2004 13:40:10 +0000, Gunnar Hjalmarsson wrote: Michael wrote: I am implementing a script that my client wants on their website. Within the script there are several "require" statements. Any time one of these "require" statements is executed, the script terminates.
Any ideas how I might solve this problem?
How about installing the modules that it tries to require? Just a thought.
The files are installed just where I believe they need to be. Here is the
code that is giving me the problem:
&require_supporting_libraries
(__FILE__, __LINE__,
"$path/file1.cfg",
"$path/file2.cfg",
"$path/library/file3.pl",
"$path/html/file4.pl",
"$path/library/file5.pl");
sub require_supporting_libraries
{
local ($file, $line, @require_files) = @_; local ($require_file);
foreach $require_file (@require_files)
{
if (-e "$require_file" && -r "$require_file")
{
print "$require_file <br><br>";
require '$require_file';
}
}
}
When I run the code the path and name of the first file is printed to the
browser window. Only the first file is listed. If I comment out the
require statement, all of the files are listed. Clearly the code is
finding the files (as it makes it into the if code block) but when the
require statement is executed, the code terminates.
rats.
Is there a problem with the syntax of the require statement? Or maybe the
permissions of the files needs to be different?
Any ideas will be appreciated.
Cheers!
Michael wrote: require '$require_file';
<snip>
Is there a problem with the syntax of the require statement?
Yes, it tries to require a file *literally* named '$require_file'.
Remove those quotes:
require $require_file;
Or maybe the permissions of the files needs to be different?
It seems to be checking for that.
You posted a piece of buggy code written for a several years old Perl
generation (Perl 4). You may want to advise your client to use a
modern quality script instead.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
On Fri, 19 Mar 2004 06:59:07 +0000, Gunnar Hjalmarsson wrote: Michael wrote: require '$require_file';
<snip>
Is there a problem with the syntax of the require statement?
Yes, it tries to require a file *literally* named '$require_file'. Remove those quotes:
require $require_file;
Or maybe the permissions of the files needs to be different?
It seems to be checking for that.
You posted a piece of buggy code written for a several years old Perl generation (Perl 4). You may want to advise your client to use a modern quality script instead.
The code originaly did not have the quotes around $require_file. Without
the quotes the code would terminate with an error message "Internal Server
Error". So I added them to try and fix the problem, but seem to have
created another.
rats.
Michael wrote:
[...] Without the quotes the code would terminate with an error message "Internal Server Error".
This is not a Perl (or perl) error message. Check the server logs for the
real error message.
jue
Michael wrote: Gunnar Hjalmarsson wrote: Michael wrote: Is there a problem with the syntax of the require statement?
Yes, it tries to require a file *literally* named '$require_file'. Remove those quotes:
require $require_file;
The code originaly did not have the quotes around $require_file. Without the quotes the code would terminate with an error message "Internal Server Error". So I added them to try and fix the problem, but seem to have created another.
You are obviously running the script as a CGI script, which it would
have been appropriate to let us know about in your initial message.
To have the browser display a more meaningful error message, you can
add this line somewhere at the beginning of the script:
use CGI::Carp 'fatalsToBrowser';
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
On Fri, 19 Mar 2004 06:59:07 +0000, Gunnar Hjalmarsson wrote: You posted a piece of buggy code written for a several years old Perl generation (Perl 4). You may want to advise your client to use a modern quality script instead.
Hmm. Well, that might be a good idea. I typically perfer to write
my own code, but the client insists on the one that he has purchased a few
years ago and used successfully on a previous server.
What if I replaced that mess of code with:
use '$path/file1.cfg';
use '$path/file2.cfg';
use '$path/library/file3.pl';
use '$path/html/file4.pl';
use '$path/library/file5.pl';
Given that I have read that
use somemodule();
is equivalent to:
BEGIN {require somemodule}
I figure that an attempt to make this code work will be less time than
rewriting it.
Michael wrote: On Fri, 19 Mar 2004 06:59:07 +0000, Gunnar Hjalmarsson wrote: You posted a piece of buggy code written for a several years old Perl generation (Perl 4). You may want to advise your client to use a modern quality script instead. Hmm. Well, that might be a good idea. I typically perfer to write my own code, but the client insists on the one that he has purchased a few years ago and used successfully on a previous server.
What if I replaced that mess of code with:
use '$path/file1.cfg'; use '$path/file2.cfg'; use '$path/library/file3.pl'; use '$path/html/file4.pl'; use '$path/library/file5.pl';
What happened when you tried it?
Honestly, if you are writing scripts for a client, you should know the
answer to that, or you should at least be able to figure it out
without asking here.
If you don't have access to the server's error log, did you try my
advice to load the CGI::Carp module and import the 'fatalsToBrowser'
routine?
Given that I have read that
use somemodule();
is equivalent to:
BEGIN {require somemodule}
That's only partly true, and not relevant here, since the files you
are trying to load aren't modules, i.e. they are not *.pm files.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Gunnar Hjalmarsson wrote: Michael wrote: require $require_file;
The code originaly did not have the quotes around $require_file. Without the quotes the code would terminate with an error message "Internal Server Error". So I added them to try and fix the problem, but seem to have created another.
You are obviously running the script as a CGI script, which it would have been appropriate to let us know about in your initial message.
To have the browser display a more meaningful error message, you can add this line somewhere at the beginning of the script:
use CGI::Carp 'fatalsToBrowser';
In addition to the above advice, make sure that each of your
require files ends with
1;
so that perl will recognize that the file was included successully.
-Joe
On Sat, 20 Mar 2004 22:10:09 +0000, Gunnar Hjalmarsson wrote: If you don't have access to the server's error log, did you try my advice to load the CGI::Carp module and import the 'fatalsToBrowser' routine?
I tried it. With "require '$require_file';" I receive the following
error message: http://bfr.caseywest.com/archives/001059.html
With "require $require_file;" the script terminates without any output.
I have checked to make sure that the directory where the files are, are in
@ic. I added the directory with "use lib". I then have a "print @INC;"
statement that outputs all of the directories in @INC and it does print
the one where the files I need are. However, when I use the second
version of the $require statement (the one without single quotes) there is
no output from the script.
Cheers!
Michael wrote: On Sat, 20 Mar 2004 22:10:09 +0000, Gunnar Hjalmarsson wrote: did you try my advice to load the CGI::Carp module and import the 'fatalsToBrowser' routine? I tried it. With "require '$require_file';" I receive the following error message:
http://bfr.caseywest.com/archives/001059.html
That is not an error message.
With "require $require_file;" the script terminates without any output.
I have checked to make sure that the directory where the files are, are in @ic. I added the directory with "use lib". I then have a "print @INC;" statement that outputs all of the directories in @INC and it does print the one where the files I need are. However, when I use the second version of the $require statement (the one without single quotes) there is no output from the script.
I have a feeling that you may be messing up the paths. If the $path
variable contains the *full* path to the directory, there should not
be a need to add any "use lib" statement. You'd better ensure that
$path is the full path. (As long as the $path variable contains
anything, but something else but the full path, a "use lib" statement
won't help.)
Also, did you see Joe's advice?
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
On Sat, 20 Mar 2004 23:49:57 +0000, Gunnar Hjalmarsson wrote: http://bfr.caseywest.com/archives/001059.html That is not an error message.
Oops. It should have been:
Can't locate $require_file in @INC With "require $require_file;" the script terminates without any output.
I have checked to make sure that the directory where the files are, are in @ic. I added the directory with "use lib". I then have a "print @INC;" statement that outputs all of the directories in @INC and it does print the one where the files I need are. However, when I use the second version of the $require statement (the one without single quotes) there is no output from the script.
I have a feeling that you may be messing up the paths. If the $path variable contains the *full* path to the directory, there should not be a need to add any "use lib" statement. You'd better ensure that $path is the full path. (As long as the $path variable contains anything, but something else but the full path, a "use lib" statement won't help.)
I believe that $path contains the full path to the files. I printed the
path out in the loop just before each "require" statement and it is the
path to the files as far as I know them to be, unless the server is using
some kind of aliasing or symbolic links that I am unaware of.
Also, did you see Joe's advice?
I did see Joe's advice. Each file has the "1;" at the end.
Cheers!
On Sun, 21 Mar 2004 00:41:26 +0000, Gunnar Hjalmarsson wrote: Another idea is to replace
require $require_file;
with
eval { require $require_file }; die $@ if $@;
I get the same result with both. Script terminates with no output.
rats.
I appreciate your help, but I feel that I must have taken up more of your
time than this little problem of mine deserves.
I believe I have two options:
1) continue to struggle to get this script to work.
2) rewrite it from scratch. Of course in this option I would likely
rewrite it in a scripting language that I have more experience with (PHP
or Python)
I really do appreciate your efforts and your patience with my lack of Perl
knowledge.
Cheers!
On Thu, 18 Mar 2004 06:50:47 -0500, Michael wrote:
Guten Morgen Once Again,
Well, instead of fighting with the script all weekend long, or porting it
over to another language, I queried the client to make certain that this
was indeed the correct code to install on the server. The client sent the
code again. This time it runs.
It turns out the code was edited and zipped in Windows. When I unzipped
it in Linux the files turned out a bit differently (I understand the
unzipping in Linux does not strip out some DOS/Windows carriage returns).
I went back and unzipped the original code given by the client in Windows
and then re-installed it and again it worked.
My face is as red as my socks.
rats.
Cheers! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Phil Powell |
last post by:
I'm sorry but I can't figure out how to explain this any better than
this.
In PHP we have a command "require()" that obtains a file and logically
places it into another file.
I cannot figure...
|
by: Mxsmanic |
last post by:
The require() I'm using in a PHP script has stopped working after I
moved from PHP4 and Apache 1.3.x to PHP5 and Apache 2.x. Now I get
messages like this:
Warning:...
|
by: Don |
last post by:
I have a set of modules that all have the same interface, and package name:
_______________________________
package dataSourcePackage;
# Initialize global variables
$hashOne{'uniquekey1'} =...
|
by: Yeah |
last post by:
Is it absolutely necessary to include "http://" in an A HREF hyperlink?
Would it be wise to remove this from one's Links page, just to save code?
|
by: Jim Carlock |
last post by:
I've set up the following using an Alias in Apache...
Alias /phpdocs/ "C:/Apache/htdocs/common/docs/php/"
<Directory "C:/Apache/htdocs/common/docs/php">
Options Indexes FollowSymlinks MultiViews...
| |
by: yaru22 |
last post by:
when I read a book, it just said we need to do
import pygtk
pygtk.require("2.0")
import gtk
in order to import gtk modules
What is that pygtk.require("2.0") command for?
|
by: =?Utf-8?B?Sm9obiBC?= |
last post by:
A windows forms 2.0 ClickOnce deployment fails when both SSL is enabled and
"require client certificate" enabled on the IIS deployment web server.
Can anyone assist with how to configure this...
|
by: lister |
last post by:
Hi all,
I have a fairly diverse range of data that I want to cache in the
session rather than pulling it from the database on every page
refresh.
The problem is is that it seems that PHP...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |