[mapserver-users] On the mapserv CGI environment

Colin Wetherbee cww at denterprises.org
Tue Feb 26 19:20:43 EST 2008


Greetings.

I'm trying to use mapserv in a CGI environment by executing it in 
mod_perl.  This is to perform input sanitizing, as Milo and I discussed 
in a thread earlier today.

My Perl code looks like this:

$ENV{QUERY_STRING} =
   "map=$mapFile&username=$username&" . $ENV{QUERY_STRING};
my $mapServ = '/usr/lib/cgi-bin/mapserv';
my $data = `$mapServ`;

The response I get in $data is:

This script can only be used to decode form results and
should be initiated as a CGI process via a httpd server.

When I invoke mapserv as above, the environment looks like this:

SCRIPT_NAME -> /jet-set/mapTile
SERVER_NAME -> 192.168.171.100
HTTP_REFERER -> http://192.168.171.100/jet-set/userJourneysBasicMap
SERVER_ADMIN -> cww at denterprises.org
HTTP_ACCEPT_ENCODING -> gzip,deflate
HTTP_CONNECTION -> keep-alive
REQUEST_METHOD -> GET
HTTP_ACCEPT -> image/png,*/*;q=0.5
SCRIPT_FILENAME -> 
/home/cww/sites/js.iron.denterprises.org/htdocs/jet-set/mapTile
SERVER_SOFTWARE -> Apache/2.2.8 (Debian) mod_apreq2-20051231/2.6.0 
mod_perl/2.0.3 Perl/v5.8.8
HTTP_ACCEPT_CHARSET -> ISO-8859-1,utf-8;q=0.7,*;q=0.7
QUERY_STRING -> 
map=/home/cww/sites/js.iron.denterprises.org/etc/js.map&username=cww&LAYERS=airports,journeys,airport_iata&TRANSPARENT=true&FORMAT=image%2Fpng&BUFFER=1&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A4326&BBOX=-203.5546875,-94.921875,203.5546875,94.921875&WIDTH=1158&HEIGHT=540
REMOTE_PORT -> 57072
HTTP_USER_AGENT -> Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; 
rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12
SERVER_PORT -> 80
SERVER_SIGNATURE -> <address>Apache/2.2.8 (Debian) 
mod_apreq2-20051231/2.6.0 mod_perl/2.0.3 Perl/v5.8.8 Server at 
192.168.171.100 Port 80</address>\n
HTTP_ACCEPT_LANGUAGE -> en-us,en;q=0.5
HTTP_COOKIE -> longCredential=cww.{removed}; sessionCredential=cww.{removed}
REMOTE_ADDR -> 192.168.171.80
HTTP_KEEP_ALIVE -> 300
SERVER_PROTOCOL -> HTTP/1.1
MOD_PERL_API_VERSION -> 2
PATH -> /usr/local/bin:/usr/bin:/bin
REQUEST_URI -> 
/jet-set/mapTile?LAYERS=airports,journeys,airport_iata&TRANSPARENT=true&FORMAT=image%2Fpng&BUFFER=1&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A4326&BBOX=-203.5546875,-94.921875,203.5546875,94.921875&WIDTH=1158&HEIGHT=540
GATEWAY_INTERFACE -> CGI/1.1
SERVER_ADDR -> 192.168.171.100
DOCUMENT_ROOT -> /home/cww/sites/js.iron.denterprises.org/htdocs
HTTP_HOST -> 192.168.171.100
MOD_PERL -> mod_perl/2.0.3

This [0] seems simple enough, and it works.  I basically just replicated 
its functionality inside Perl.

What am I missing?

Thanks.

Colin

[0] http://mapserver.gis.umn.edu/docs/howto/cgi-wrapper-script


More information about the mapserver-users mailing list