Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: cgi environment using mod_perl

by Coruscate (Sexton)
on Jan 21, 2004 at 05:25 UTC ( [id://322830]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to cgi environment using mod_perl

When under a mod_perl environment, the directory that the perl script is started in can differ from the directory in which the script file itself is located. I'm not sure if it is always the case, but my mod_perl starts scripts up from the apache root (So in my case C:/Apache2/www/port80/serve/foo.pl is executed as though it were C:/Apache2/foo.pl). The simplest way to make it back to regular CGI behaviour is to change directory from within perl. So at the top of your script, you just throw in this line:

BEGIN { chdir "/path/to/script/directory" }

My foo.pl script as mentioned above for example, would include this line:

BEGIN { chdir "C:/Apache2/www/port80/serve" }

Replies are listed 'Best First'.
Re: Re: cgi environment using mod_perl
by perrin (Chancellor) on Jan 21, 2004 at 12:52 UTC
    That's only the case with mod_perl 2. In mod_perl 1, Apache::Registry does the chdir automatically.

      I'll remember that in case I ever have to suffer the long journey of porting anything from mod_perl 1.x to mod_perl 1.9x/2.x. That would certainly be a strange thing to see happen if you're not expecting it. :)

        There's a documented workaround for it if you're using prefork. The problem is that chdir is not safe when using threads.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://322830]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.