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

Discussion in 'Perl Misc' started by Derf, Oct 6, 2003.

  1. Derf

    Derf Guest

    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";
     
    Derf, Oct 6, 2003
    #1
    1. Advertising

  2. In article <Xns940CB5135666Cwunkalunkaelviscom@24.28.95.190>,
    Derf <> wrote:

    > 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.

    --
    Michael Budash
     
    Michael Budash, Oct 6, 2003
    #2
    1. Advertising

  3. Derf <> wrote in message news:<Xns940CB5135666Cwunkalunkaelviscom@24.28.95.190>...
    > 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
     
    James Willmore, Oct 7, 2003
    #3
  4. Derf

    Derf Guest

    (James Willmore) wrote in
    news::
    > 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
     
    Derf, Oct 7, 2003
    #4
  5. Derf

    Derf Guest

    Derf <> wrote in
    news:Xns940D239D5BBE4wunkalunkaelviscom@24.28.95.150:
    >

    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.
     
    Derf, Oct 7, 2003
    #5
  6. Derf

    Anno Siegel Guest

    Derf <> wrote in comp.lang.perl.misc:
    > (James Willmore) wrote in
    > news::
    > > 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...


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

    Anno
     
    Anno Siegel, Oct 7, 2003
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luqman
    Replies:
    1
    Views:
    657
    Luqman
    Feb 7, 2006
  2. Luigi Donatello Asero

    Let or not let the text float

    Luigi Donatello Asero, Jan 15, 2004, in forum: HTML
    Replies:
    6
    Views:
    473
    Steve R.
    Jan 15, 2004
  3. N3TB1N
    Replies:
    2
    Views:
    422
    rossum
    May 10, 2004
  4. MRAB
    Replies:
    4
    Views:
    311
  5. Derf
    Replies:
    3
    Views:
    243
    Bob Walton
    Oct 7, 2003
Loading...

Share This Page