A stupid question...

Linda Moet lindam at gwnsys.ca
Mon Nov 8 12:26:30 EST 1999

Hi Duncan,

To help get you going, here are some random thoughts on what has to happen
to make GRASS accessible over the Internet:

1)  First, GRASS has to start.  Starting GRASS over the web consists of
setting a bunch of environment variables and locking a mapset so multiple
web surfers don't interfere with each other.  The Programmers' Manual has a
chapter on Environmental Variables that will help you understand what is
going on.

2)  In order for a web user to access a mapset, they must own it.  (There
was a discussion on the list a short while ago about sharing mapsets and why
it isn't possible - only the owner of a mapset can access it.)  Since all
web users will appear to be user "nobody" to GRASS (because most web servers
like Apache run as some rights-restricted user like "nobody"), you must have
a mapset (or several) that is owned by nobody.  This can be accomplished by
going in as root into the directory spearfish, say, and:
    mkdir wwwgrass
    chown nobody wwwgrass
    chgrp grassadmin wwwgrass
    chmod 775 wwwgrass
This arrangement allows user "nobody", i.e. the web server, to access the
mapset, and members of the group grassadmin (assuming root set that up too)
to modify this directory and its contents if necessary.

3)  You now know enough to write a simple script that will make GRASS go
over the net:

STEP A:  write a .grassrc file in the wwwgrass directory you made in item 2
GISDBASE: /usr/local/grass42/grassdata
LOCATION_NAME: spearfish
LOCATION: /usr/local/grass42/grassdata/spearfish/wwwgrass
MAPSET: /wwwgrass

STEP B:  write a shell script called testgrass.sh:
# A very small one-function test script that makes GRASS go on the Net
echo -e "Content-type: text/plain\n\n"
export GISBASE="/usr/local/grass42"
export GIS_LOCK=$$
export GISRC="${GISBASE}/grassdata/spearfish/wwwgrass/.grassrc"
${GISBASE}/bin/g.list type=rast

STEP C: Take care of miscellaneous gotcha's:
 - the script must be executable ("chmod 755 testgrass.sh"), and in a
directory that your web server will allow CGI scripts to be placed
 - the web server must recognize .sh as a CGI-executable extension; try
renaming to .cgi if necessary
 - don't forget that your first line of output has to be the "Content-type:"
HTTP header followed by a blank line

STEP D: Test!
You should see a list of raster files output in the browser window when you
access the URL:
If it doesn't work, read the last few lines of your web server's error log.
On my Red Hat 5.2 system, this can be done with the command:
    tail /etc/httpd/logs/error_log

4)  GRASS has essentially two kinds of output:  text and pictures.  Text is
easy enough to send out over an HTTP connection, but there is an extra
conversion step necessary when outputting images - they must be first
converted to GIF or JPEG or PNG (a note about GIF:  if you haven't heard
about the licensing idiocy regarding GIFs, then visit www.burnallgifs.org
before you choose this format.)  How to do this is a rather long story in
itself.  Try reading the GRASSLinks source code to see how it is done.
There are also instructions in the GRASS FAQ on using the CELL driver to
output images, which must then be converted to gif, jpg, or png.

5)  Know something about CGI and server security, or talk to someone who

6)  All the above works on my Linux Red Hat 5.2 /GRASS 4.2.1 system, where I
have installed GRASS in /usr/local/grass42 and all my locations (spearfish,
etc.) are subdirectories under /usr/local/grass42/grassdata .  Your mileage
may vary.

I hope you find some of this useful, Duncan.  If you have a lot of detailed
questions that aren't appropriate for the newsgroup, you can email me
personally and I will try to help. Just for laughs, I am currently writing
my own web interface to GRASS and I have made a great many mistakes and a
few successes that you may find instructive.  =+)

Linda Moet
Programmer Analyst
GWN Technologies
Edmonton, Alberta, Canada
lindam at gwnsys.ca

-----Original Message-----
From: Duncan Kinder <dckinder at mountain.net>
To: grass at cecer.army.mil <grass at cecer.army.mil>
Date: Saturday, November 06, 1999 2:00 PM
Subject: Re: A stupid question...

>Whatever it takes to make GRASS, GRASSLinks, and / or whatever to go on the
>If I knew more, I would be able to phrase the question better.
>Duncan C. Kinder
>dckinder at mountain.net
>----- Original Message -----
>From: <Bruce_Byars at baylor.edu>
>To: <grass at cecer.army.mil>
>Sent: Friday, November 05, 1999 2:52 PM
>Subject: Re: A stupid question...
>> Link what up?  GRASS?
>> Duncan Kinder wrote:
>> > How do I link this up with Linux and Apache?
>> >
>> > Regards,
>> >
>> > Duncan C. Kinder
>> > dckinder at mountain.net
>> >
>> > ----- Original Message -----
>> > From: Venkatesh Raghavan <raghavan at media.osaka-cu.ac.jp>
>> > To: <grass at cecer.army.mil>
>> > Sent: Tuesday, November 02, 1999 6:59 PM
>> > Subject: Re: A stupid question...
>> >
>> > > Hi,
>> > >
>> > > GRASSLinks is a Web Interface to GRASS GIS.
>> > > It enables to execute GRASS commands from
>> > > a Web Browser. The older version of GRASSLinks
>> > > consists of a set of UNIX shell scripts and a few
>> > > C routines. The new version3.1 is written in Perl.
>> > >
>> > > Some demos of GRASSLinks can be accessed form
>> > >
>> > > http://www.geog.uni-hannover.de/grass/applications.html
>> > >
>> > > Hope this helps
>> > >
>> > >
>> > > Angela wrote:
>> > >
>> > > > Hi,
>> > > >
>> > > >     I am a new user of GRASS...
>> > > > I want to know that what is the relationship with GRASS and
>> > > > Could anybody tell me?   Thank you...
>> > > >
>> > > > Best regards,
>> > > >
>> > > > Angela
>> > >
>> > >
>> > >
>> > >

More information about the grass-user mailing list