You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Colin Wetherbee <cw...@denterprises.org> on 2008/02/28 00:27:51 UTC

Executing CGI programs from within mod_perl

Greetings.

I use a program called MapServer to generate images.  It's a C binary, 
and most people seem to run it (essentially) directly as a CGI program. 
  By essentially, I mean the binary is typically requested by JavaScript 
or Flash or other things like that.

I'm doing some dynamic mapping that requires additional CGI variables, 
though, and I'd like to process and sanitize those from within an 
existing mod_perl application I have.

I wrote a post [0] about this to the MapServer list last night, but 
nobody has responded, so I figured I'd try over here to see if any of 
you have some insight as to the problem.

Basically, I'd like to run the 'mapserv' binary from within mod_perl, 
but it requires a CGI environment to be setup for it.  Apparently, my 
environment is missing something it requires.  The environment from %ENV 
is listed in the post to the MapServer list.

I seem to remember something about backticks doing some localized 
environment things, but I couldn't really find anything on it in the 
archives.

Is this something I can do from within mod_perl?

Thanks.

Colin

[0] 
<http://lists.osgeo.org/pipermail/mapserver-users/2008-February/054531.html>

Re: Executing CGI programs from within mod_perl

Posted by Perrin Harkins <pe...@elem.com>.
On Thu, Feb 28, 2008 at 9:47 PM, Colin Wetherbee <cw...@denterprises.org> wrote:
>  I've tried both with the $r that gets passed into handler and the $r
>  from Apache2::RequestUtil->request.

Both of those should have worked.  What happened?

>  Is there any way around this short of setting +GlobalRequest?

Calling Apache2::RequestUtil->request() requires this to be on, but
the $r that gets passed to the handler does not.

>  I believe
>  I've read before that there's a performance hit if +GlobalRequest is set.

Only if you're running a threaded MPM.  Unless you're on Windows, you
should not be running threads.

- Perrin

Re: Executing CGI programs from within mod_perl

Posted by Colin Wetherbee <cw...@denterprises.org>.
Michael Peters wrote:
> Colin Wetherbee wrote:
> 
>> Basically, I'd like to run the 'mapserv' binary from within mod_perl
> 
> Why? Don't you just want to sanitize the data? If so you can do that in a
> FixUpHandler or even in a separate handler that does an internal_redirect to the
> mapserv's url.

I tried your suggestion, but, in my PerlFixUpHandler, I get the 
following error.

Global $r object is not available. Set:\n\tPerlOptions 
+GlobalRequest\nin httpd.conf

I need $r in order to do cookie and URL processing.

I've tried both with the $r that gets passed into handler and the $r 
from Apache2::RequestUtil->request.

Is there any way around this short of setting +GlobalRequest?  I believe 
I've read before that there's a performance hit if +GlobalRequest is set.

Thanks.

Colin

Re: Executing CGI programs from within mod_perl

Posted by Colin Wetherbee <cw...@denterprises.org>.
Michael Peters wrote:
> Colin Wetherbee wrote:
> 
>> Basically, I'd like to run the 'mapserv' binary from within mod_perl
> 
> Why? Don't you just want to sanitize the data? If so you can do that in a
> FixUpHandler or even in a separate handler that does an internal_redirect to the
> mapserv's url.

I also want to do cookie processing.  And, I think this is going to 
get more complicated down the road, so I'd like to leave my options open.

Colin


Re: Executing CGI programs from within mod_perl

Posted by Michael Peters <mp...@plusthree.com>.
Colin Wetherbee wrote:

> Basically, I'd like to run the 'mapserv' binary from within mod_perl

Why? Don't you just want to sanitize the data? If so you can do that in a
FixUpHandler or even in a separate handler that does an internal_redirect to the
mapserv's url.

-- 
Michael Peters
Plus Three, LP