[GRASS-dev] File based GRASS batch processing?

Glynn Clements glynn at gclements.plus.com
Mon Jan 22 17:34:59 EST 2007


Markus Neteler wrote:

> I often have to process large data sets on remote
> machines which takes more than a day. Since I
> cannot keep the ssh connection open for so long,
> it would be very convenient to have the possibility
> to pass a file (containing GRASS commands) as
> parameter to the startup script, say something like:
> 
> nohup grass63 -text -batch myjobs.sh ~/grassdata/spearfish60/neteler/ &
>                     ^^^^^^^^^^^^^^^^
> 
> I assume that this would require changes in lib/init/init.*
> (maybe for now only lib/init/init.sh).
> 
> Before wasting time on this, any suggestions for a best
> implementation? Maybe I am overlooking an easy solution.

As a quick hack, you could try setting SHELL to ./myjobs.sh, so that
Init.sh runs the script instead of an interactive shell. However,
myjobs.sh should probably set SHELL back to e.g. /bin/sh in case
anything which is run from it uses $SHELL.

But adding a -batch switch to Init.sh wouldn't be that hard.

FWIW, I just set up a GRASS environment in my ~/.bash_profile so that
GRASS commands work in every shell:

	export GISBASE=/opt/grass-6.3.cvs
	export GRASS_GNUPLOT='gnuplot -persist'
	export GRASS_WIDTH=640
	export GRASS_HEIGHT=480
	export GRASS_HTML_BROWSER=firefox
	export GRASS_PAGER=cat
	export GRASS_PERL=perl
	export GRASS_TCLSH=tclsh
	export GRASS_WISH=wish
	
	export PATH="$GISBASE/bin:$GISBASE/scripts:$PATH"
	export LD_LIBRARY_PATH="$GISBASE/lib"
	export GRASS_LD_LIBRARY_PATH="$LD_LIBRARY_PATH"
	
	export GIS_LOCK=$$
	export GRASS_VERSION="6.1.cvs"
	
	tmp=/tmp/grass6-"`whoami`"-$GIS_LOCK
	export GISRC="$tmp/gisrc"
	mkdir "$tmp"
	cp ~/.grassrc6 "$GISRC"

Also, my ~/.xsession script sources ~/.bash_profile, so all X
applications are part of a GRASS session, so I can run GRASS commands
using M-! in XEmacs.

The only time I actually start a separate GRASS session is via
bin.<arch>/grass63, when I want to run a just-compiled version without
installing it.

[The only downside is that I have to remember to manually delete all
of the /tmp/grass-glynn-* and /opt/grass-data/*/*/.tmp/* directories
occasionally.]

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list