[GRASSLIST:1465] Re: Initialising Grass Script From cron

Scott O'Donnell odonnell at fsl.noaa.gov
Thu Feb 15 12:08:08 EST 2001

Hi Izak,

Marcus' instructions are nice to know about, but if you don't run GRASS-5.0
yet I don't think it answers your question.

I'm still using GRASS-4.3 (similar to your version) and being a traditional 
UNIX user (Linux & HPUX), Iprefer to invoke GRASS functions from the 
command line and from scripts, rarely using interactive interface/s.

To guarantee a proper runtime environment for GRASS-4.3, I define my default 
GRASS environment variables in my startup  script, '.cshrc' (my default 
shell is tcsh).  I initialize my environment variables using the following 
commands (remember I use tcsh, so you may need to adapt these definitions 
for your preferred shell)...

setenv GISDBASE      ${HOME}/Grass/db
setenv GISRC         ${HOME}/.grassrc
setenv MAPSET         24K

(Of course, you must make the necessary directory substitutions)

When I need to access another dataset, I run scripts to redefine these 
variables as necessary.  Also, I have '.grassrc' files for each of my 
datasets and copy the relevant grass resource file to my home directory.

Having done this, my scripts and command line operations ALWAYS
do the right things and I don't struggle with defining the "right"
environment any more.  

It's nice to know how to define my working environment when I get to 
GRASS-5.0, but until then, this method works well for me.

Hope this helps,
Scott O'Donnell

Markus Neteler wrote:
> On Thu, Feb 15, 2001 at 03:56:26PM +0200, Izak Thomas Henry Deyzel wrote:
> > Good Day Everyone,
> >
> > I am using Grass4.2.1. I am trying to automise my whole process of data
> > manipulation and map production. I am using a bash script to do the
> > grass stuff, but need to intialise this script from a cron. Grass and
> > its dbase is running the whole time, but the cron runs in its own
> > environment oblivious of Grass dbase. I test for the db being active and
> > receive errors. Is there a method of exporting Grass' environmental
> > variables so that my cron environment will be aware of the dbase or is
> > there a method of intialising Grass and its dbase within the cron
> > script:
> >
> > e.g. grass4.2 <<-script
> > .....grass stuff....
> > exit
> > script
> >
> > Thank you.
> >
> Hi Izak,
> you may have a look here:
> http://www.geog.uni-hannover.de/grass/faq/index.html#problems
> ->
>     How to use GRASS in batch mode (fully script based)?:
> This has been simplified in GRASS 5:
> grass5 -help
> Usage:
>     grass5 [-h | -help | --help] [-text | -tcltk] [[[<GISDBASE>/]<LOCATION_NAME>/]<MAPSET>]
> Flags:
>     -h or -help or --help          print this help message
>     -text                          use text based interface
>     -tcltk                         use Tcl/Tk based graphical interface
> Parameters:
>     GISDBASE                       initial database
>     LOCATION_NAME                  initial location
>     MAPSET                         initial mapset
>     GISDBASE/LOCATION_NAME/MAPSET  fully qualified initial LOCATION directory
> Environment variables:
>     GRASS_TCLSH                    set tclsh shell name to override 'tclsh'
>     GRASS_WISH                     set wish shell name to override 'wish'
> Hope this helps,
>  Markus Neteler

"A successful tool is one that was used      | Scott O'Donnell  
 to do something undreamed of by its author."| odonnell at fsl.noaa.gov
                   -- S. C. Johnson          | 303 497 6562

More information about the grass-user mailing list