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!

simple requires not being found IIS

Status
Not open for further replies.

clemrock

Programmer
May 20, 2004
118
0
0
US
Hello,

I'm trying to migrate a Perl site from a linux server to IIS. Everytime I try to require another perl script I get an error that the file cannot be found.

Even when the file is in the same directory - the same error still comes up:

Code:
#!/usr/bin/perl  
use CGI::Carp "fatalsToBrowser";  
use CGI ":all"; use MD5; use strict;  
use CGI qw(:standard);  
 
print "Content-type:text/html\n\n";  
 
 
require "common_functions.pl";

What could I be missing here?
 
Try checking your include.

Code:
#!/usr/bin/perl  
use CGI::Carp "fatalsToBrowser";  
use CGI ":all"; use MD5; use strict;  
use CGI qw(:standard);  
 
print "Content-type:text/html\n\n";  
 
[COLOR=green]print join "<br>\n", @INC;[/color]

Also try using an explicit path. It never hurts to at least do a sanity check.
 
Yeah - I've had to do that on linux boxes.

Why can't you do simple relative paths in IIS?
 
You can use relative paths. It all depends on what your @INC is which is what it checks the relative paths against. You just can't use a web address in a require.
 
unfortunately, IIS doesn't seem to offer an equivelent to the $EVN{'DOCUMENT_ROOT'} var.

If my @INC prints this:
C:/Perl/lib
C:/Perl/site/lib

How could I use that to my advantage?
 
Read me:
This will show you how to add directories to your @INC. Unfortunately, you haven't yet told us what the proper path is for common_functions.pl. You have one of two options.

Code:
require 'C:/i/likes/duckies/cgi-bin/test/admin/common_functions.pl';

OR

Code:
use lib 'C:/i/likes/duckies/cgi-bin/test/admin/';

require 'common_functions.pl';

Either method works. You just need to substitute i/likes/duckies with the real path to this file.
 
This works nicely.

the only thing is a security question:

My cgi-bin is a virtual directory that's located here:

D:/Websites/website_com/cgi-bin

the actual directory where the perl scripts are located is here:
D:/Websites/website_com/test/perl_scripts


The only way I can add the path to the lib module is by pointing it to the actual perl_scripts directory and not the cgi-bin directory as such:

use lib 'D:/Websites/website_com/test/perl_scripts/test/admin/';

wouldn't it be preferable to be pointing it to the cgi-bin?

Thanks again for all your help.




 
wouldn't it be preferable to be pointing it to the cgi-bin?

Shouldn't make any difference. But you might want to make sure the folder that does have the perl scripts in them is not accessible to the public.

- Kevin, perl coder unexceptional!
 
Can you add "../test/perl_scripts" to your @INC, or doesn't it work like that?

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
stevexff said:
Can you add "../test/perl_scripts" to your @INC, or doesn't it work like that?

Yes, relative paths work just fine, but it's much better practice to use absolutely paths for predictable reasons.

Code:
use Cwd qw(abs_path);
use lib abs_path('../test/perl_scripts');

Of course even in the above example, you may be making an assumption concerning what the current active directory is at compile time. There are modules like FindBin that help with this issue, and then again, there is also creative use of BEGIN and lib->import. But this might be complicating your question.

Yes, relative paths are possible.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top