473,657 Members | 2,597 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"require" problem?

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!
Jul 19 '05 #1
15 6065
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

Jul 19 '05 #2
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_suppor ting_libraries
(__FILE__, __LINE__,
"$path/file1.cfg",
"$path/file2.cfg",
"$path/library/file3.pl",
"$path/html/file4.pl",
"$path/library/file5.pl");

sub require_support ing_libraries
{
local ($file, $line, @require_files) = @_; local ($require_file) ;

foreach $require_file (@require_files )
{
if (-e "$require_f ile" && -r "$require_file" )
{
print "$require_f ile <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!
Jul 19 '05 #3
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

Jul 19 '05 #4
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.

Jul 19 '05 #5
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
Jul 19 '05 #6
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 'fatalsToBrowse r';

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Jul 19 '05 #7
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.
Jul 19 '05 #8
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 'fatalsToBrowse r'
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

Jul 19 '05 #9
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 'fatalsToBrowse r';


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
Jul 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2986
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 out how to do this in bash script as the requirement is necessary for a migration script to obtain the code from a .cfg file and then be able for the "parent" script to run the code it "imported" from the .cfg file, much like PHP's require() or...
4
2799
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: main(/includes/ReloadScript.html) : failed to open stream: No such file or directory in /usr/local/www/htdocs/main/AOLCompression.php on line 14 Fatal error: main() : Failed opening required '/includes/ReloadScript.html' (include_path='.:/usr/local/lib/php') in
2
2616
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'} = "value1"; $hashOne{'uniquekey2'} = "value1"; sub requiredMethod1()
31
4845
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?
5
3204
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 AllowOverride None Order allow,deny Allow from all </Directory>
1
5051
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?
2
4240
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 properly or at least confirm if it will just not work? When not requiring the client certificate the deployment site works fine. However, when I set SSL to "require client certificate" I am prompted for a client cert when I initially open the url....
5
2202
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 requires the class definitions available on EVERY page, as it unserialises everything even if it's not going to be used.
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8823
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8730
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8605
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7321
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5632
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1950
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1607
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.