require and do - absolute vs relative - let me try again

D

Derf

I have a file at /path/from/root/cgi-bin/file.pl

and I want to require /path/from/root/cgi-bin/dir/requirefile.pl

the web root would be /cgi-bin/file.pl and the user root would be
/path/from/root/cgi-bin/file.pl

when i use an absolute path in file.pl:

do "/path/from/root/cgi-bin/dir/requirefile.pl";

or

require "/path/from/root/cgi-bin/dir/requirefile.pl";

i get the error

***corrected error from previous message:

Can't do: No such file or directory at /path/from/root/cgi-
bin/file.pl line ##.

but if I move file.pl to /path/from/root/cgi-bin/dir/file.pl

and then do a relative call:

require "requirefile.pl";

or

do "requirefile.pl";
 
M

Michael Budash

Derf said:
I have a file at /path/from/root/cgi-bin/file.pl

and I want to require /path/from/root/cgi-bin/dir/requirefile.pl

the web root would be /cgi-bin/file.pl and the user root would be
/path/from/root/cgi-bin/file.pl

when i use an absolute path in file.pl:

do "/path/from/root/cgi-bin/dir/requirefile.pl";

or

require "/path/from/root/cgi-bin/dir/requirefile.pl";

i get the error

***corrected error from previous message:

Can't do: No such file or directory at /path/from/root/cgi-
bin/file.pl line ##.

but if I move file.pl to /path/from/root/cgi-bin/dir/file.pl

and then do a relative call:

require "requirefile.pl";

or

do "requirefile.pl";

here's what i'd do:

try:

require './dir/requirefile.pl';

if that doesn't work, you'll need to determine what the actual path is
and use that. assuming unix (and why not?), put in a:

print `pwd`;

to figure it out.
 
J

James Willmore

Derf said:
I have a file at /path/from/root/cgi-bin/file.pl

and I want to require /path/from/root/cgi-bin/dir/requirefile.pl

the web root would be /cgi-bin/file.pl and the user root would be
/path/from/root/cgi-bin/file.pl

when i use an absolute path in file.pl:

do "/path/from/root/cgi-bin/dir/requirefile.pl";

or

require "/path/from/root/cgi-bin/dir/requirefile.pl";

i get the error

***corrected error from previous message:

Can't do: No such file or directory at /path/from/root/cgi-
bin/file.pl line ##.

but if I move file.pl to /path/from/root/cgi-bin/dir/file.pl

and then do a relative call:

require "requirefile.pl";

or

do "requirefile.pl";

Huh? Try again using something like "/a/b/c/file.pl" instead of what
you used to describe the issue. Maybe after doing that, you may find
your error and not need to post ... because, it looks as though you're
confussed about where the files are. I know I am :)

Seriously, you _should_ be able to execute another script from another
location using an absolute path. You may want to check your
permissions and, as always, try the script from the command line to
see what happens.

HTH

Jim
 
D

Derf

(e-mail address removed) (James Willmore) wrote in
Huh? Try again using something like "/a/b/c/file.pl" instead of what
you used to describe the issue. Maybe after doing that, you may find
your error and not need to post ... because, it looks as though you're
confussed about where the files are. I know I am :)

Seriously, you _should_ be able to execute another script from another
location using an absolute path. You may want to check your
permissions and, as always, try the script from the command line to
see what happens.

HTH

Jim

I appreciate the help. I have the same problem from command line. It
turns out it is just this script. Other scripts run fine with the
absolute path. It is only this one script that says it can't be found if
I use an absolute path, but can be found if it is in the same directory
with a relative path (any other relative path fails as well "No such file
or directory"). The reqiuired script runs fine. The required script has a
couple do commands that use relative paths though. I wonder if those do
commands might need to be absolute so the require sees them. hmmmm
 
D

Derf

The reqiuired script runs fine. The
required script has a couple do commands that use relative paths
though. I wonder if those do commands might need to be absolute so the
require sees them. hmmmm

Yeah, that was it.
 
A

Anno Siegel

Derf said:
(e-mail address removed) (James Willmore) wrote in


I appreciate the help. I have the same problem from command line. It
turns out it is just this script. Other scripts run fine with the
absolute path. It is only this one script that says it can't be found if
I use an absolute path, but can be found if it is in the same directory
with a relative path...

Does the mystery script do a "chroot" by any means? Not that that has
anything to do with Perl...

Anno
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top