#2572: grass command welcomes batch job and requires user input
--------------------------------------------+-------------------------------
Reporter: wenzeslaus | Owner: grass-dev@…
Type: defect | Status: new
Priority: minor | Milestone: 6.4.5
Component: Startup | Version: 6.4.4
Keywords: GRASS_BATCH_JOB, rc file, init | Platform: Linux
Cpu: Unspecified |
--------------------------------------------+-------------------------------
When calling GRASS GIS to do a batch job without having rc file created,
one gets:
{{{
WELCOME TO GRASS Version 6.4.4 2014
...
- Current catalog of available computer maps
...
Hit RETURN to continue
}}}
This warm welcome is intended for user but when a GRASS_BATCH_JOB is set,
this should not be executed because there is usually nobody to hit RETURN
since the process is executed from some program.
Test setup:
{{{
cat > test_script.sh <<EOF
echo "Hello from GRASS GIS" > test_file.txt
date >> test_file.txt
EOF
}}}
{{{
export GRASS_BATCH_JOB=$PWD/test_script.sh
}}}
Test:
{{{
rm ~/.grassrc6
grass64 ~/grassdata/nc_spm_08_grass7_tests/user1
}}}
Here is a patch which works for me for version 6.4:
{{{
#!diff
Index: lib/init/init.sh
--- lib/init/init.sh (revision 64329)
+++ lib/init/init.sh (working copy)
@@ -421,7 +421,7 @@
fi
# First time user - GISRC is defined in the GRASS script
-if [ ! -f "$GISRC" ] ; then
+if [ ! -f "$GISRC" -a ! -n "$GRASS_BATCH_JOB" ] ; then
if [ ! -f "$GISBASE/locale/$LCL/etc/grass_intro" ] ; then
cat "$ETC/grass_intro"
}}}
I'm not sure if it is correctly implemented because it causes that the rc
file (`~/.grassrc6`) is not created (using the `$HOME` and `<UNKNOWN>`).
It does not seem useful anyway but I guess that there is some reason for
it.
Basically the same patch can be applied to version 7. Check
`GRASS_BATCH_JOB` (`batch_job`) before calling `grass_intro()`. I'm just
don't have the full understanding of the code, for example I'm not sure
how rc file is supposed to be handled with `GRASS_BATCH_JOB`
(source:grass/trunk/lib/init/grass.py?rev=64377#L1339).
A workaround for version 6.4 is to create a `.grassrc6` file in directory
specified by `$HOME` with some reasonable content (e.g. a copy of existing
`.grassrc6` from different user).
Related:
* https://hub.qgis.org/issues/5644
* http://osgeo-org.1560.x6.nabble.com/grass-shell-td3901230.html
--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2572>
GRASS GIS <http://grass.osgeo.org>