GRASS and Shell: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
(extended)
(cat)
Line 46: Line 46:


[[Category:FAQ]]
[[Category:FAQ]]
[[Category:Linking to other languages]]

Revision as of 12:23, 5 July 2006

It is fairly easy to write a GRASS job as Shell script which launches GRASS, does the operation and cleans up the temporary files.

You have to set a couple of variables to enable GRASS command to run:

  # Example in bash shell syntax:

  # path to GRASS binaries and libraries:
  export GISBASE=/usr/local/grass60

  export PATH=$PATH:$GISBASE/bin:$GISBASE/scripts
  export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GISBASE/lib

  # path to GRASS settings file (better generate this file on the fly):
  export GISRC=$HOME/.grassrc6

  # use process ID (PID) as lock file number:
  export GIS_LOCK=$$

  # settings for graphical output to PNG file (optional)
  export GRASS_PNGFILE=/tmp/grass6output.png
  export GRASS_TRUECOLOR=TRUE
  export GRASS_WIDTH=900
  export GRASS_PNG_COMPRESSION=1

Now you can test:

  # this should print the GRASS version used:
  g.version
  # other calculations go here ...

You should cleanup internal tmp files like this:

  # run GRASS' cleanup routine
  $GISBASE/etc/clean_temp

If this works, you can launch other GRASS commands. The approach works within Shell scripts and also in the command line terminal.

Example

See also