[GRASS-dev] File based GRASS batch processing?
Markus Neteler
neteler at itc.it
Mon Jan 22 18:10:20 EST 2007
On Mon, Jan 22, 2007 at 10:34:59PM +0000, Glynn Clements wrote:
> Markus Neteler wrote:
>
> > I often have to process large data sets on remote
> > machines which takes more than a day. Since I
...
>
> 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.
This seems to work.
> But adding a -batch switch to Init.sh wouldn't be that hard.
>
Attached a first sort of working hack "diff". Could be
certainly nicer.
[.. useful hints omitted.. ]
It works like this:
export GRASS_BATCH_JOB=/tmp/myjob.sh
grass63 -text ~/grassdata/spearfish60/neteler/
Markus
-------------- next part --------------
? OBJ.i686-pc-linux-gnu
? diff
Index: init.sh
===================================================================
RCS file: /home/grass/grassrepository/grass6/lib/init/init.sh,v
retrieving revision 1.99
diff -u -r1.99 init.sh
--- init.sh 8 Jan 2007 15:22:24 -0000 1.99
+++ init.sh 22 Jan 2007 23:07:20 -0000
@@ -90,6 +90,7 @@
echo " GRASS_WISH set wish shell name to override 'wish'"
echo " GRASS_HTML_BROWSER set html web browser for help pages"
echo " GRASS_ADDON_PATH set additional path(s) to local GRASS modules"
+ echo " GRASS_BATCH_JOB shell script to be processed as batch job"
exit
;;
@@ -665,6 +666,19 @@
exit 1
fi
+# hack to process batch jobs:
+if [ -x "$GRASS_BATCH_JOB" ] ; then
+ if [ ! -f "$GRASS_BATCH_JOB" ] ; then
+ echo "Batch job file $GRASS_BATCH_JOB as defined in GRASS_BATCH_JOB variable not found. Exiting."
+ exit 1
+ else
+ SHELL="$GRASS_BATCH_JOB"
+ fi
+else
+ echo "Batch job file $GRASS_BATCH_JOB as defined in GRASS_BATCH_JOB variable not found. Exiting."
+ exit 1
+fi
+
# Start the chosen GUI but ignore text
case "$GRASS_GUI" in
@@ -866,3 +880,8 @@
echo
echo "Goodbye from GRASS GIS"
echo
+if [ -x "$GRASS_BATCH_JOB" ] ; then
+ echo "Batch job $GRASS_BATCH_JOB was executed."
+ exit 0
+fi
+
More information about the grass-dev
mailing list