GRASS and Shell: Difference between revisions
Jump to navigation
Jump to search
(script to generate Earthquakes Map) |
(extended) |
||
Line 1: | Line 1: | ||
You have to set a couple of variables: | 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: | # Example in bash shell syntax: | ||
Line 9: | Line 11: | ||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GISBASE/lib | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GISBASE/lib | ||
# path to GRASS settings file: | # path to GRASS settings file (better generate this file on the fly): | ||
export GISRC=$HOME/.grassrc6 | export GISRC=$HOME/.grassrc6 | ||
Line 15: | Line 17: | ||
export GIS_LOCK=$$ | export GIS_LOCK=$$ | ||
# settings for graphical output (optional) | # settings for graphical output to PNG file (optional) | ||
export GRASS_PNGFILE=/tmp/grass6output.png | export GRASS_PNGFILE=/tmp/grass6output.png | ||
export GRASS_TRUECOLOR=TRUE | export GRASS_TRUECOLOR=TRUE | ||
Line 25: | Line 27: | ||
# this should print the GRASS version used: | # this should print the GRASS version used: | ||
g.version | 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. | If this works, you can launch other GRASS commands. The approach works within Shell scripts and also in the command line terminal. | ||
=== Example === | === Example === |
Revision as of 11:57, 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
- GRASS shell script job to generate a Recent Earthquakes Map