GRASS and Shell: Difference between revisions
Jump to navigation
Jump to search
(cat) |
(remove session tmp directory) |
||
Line 33: | Line 33: | ||
# run GRASS' cleanup routine | # run GRASS' cleanup routine | ||
$GISBASE/etc/clean_temp | $GISBASE/etc/clean_temp | ||
# remove session tmp directory: | |||
rm -rf /tmp/grass6-$USER-$GIS_LOCK | |||
If this works, you can launch other GRASS commands. The approach works within Shell scripts and also in the command line terminal. | If this works, you can launch other GRASS commands. The approach works within Shell scripts and also in the command line terminal. |
Revision as of 15:08, 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 # remove session tmp directory: rm -rf /tmp/grass6-$USER-$GIS_LOCK
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