Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: cgi environment using mod_perl

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


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 17: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
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-04-19 03:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found