Executing CGI programs from within mod_perl

Executing CGI programs from within mod_perl

am 28.02.2008 00:27:51 von Colin Wetherbee

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]

Re: Executing CGI programs from within mod_perl

am 28.02.2008 01:50:54 von mpeters

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

Re: Executing CGI programs from within mod_perl

am 28.02.2008 01:55:45 von Colin Wetherbee

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

am 29.02.2008 03:47:55 von Colin Wetherbee

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

am 05.03.2008 02:19:03 von Perrin Harkins

On Thu, Feb 28, 2008 at 9:47 PM, Colin Wetherbee 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