<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000099">
Hi,<br>
<br>
I have a shell script which writes a R script to file and then runs
it. The R script includes some calls to GRASS functions using the
execGRASS function from the spgrass6 package. This all works fine
except when I make a call to the GRASS function r.random. It will
run, but at the end of the script, the script will start from the
beginning... and this will continue till using ctrl+c. This is in
GRASS 7.0 on Ubuntu 12.10. In GRASS6.4 the same problem does not
happen.<br>
<br>
A simplified example of my script is below:<br>
<br>
<font face="Courier New, Courier, monospace">#!/bin/sh<br>
# <br>
LOGDIR="$HOME"<br>
LOGFILE="$LOGDIR/r_model_eval.log"<br>
echo "r.model.edm :" >> "$LOGFILE"<br>
writeScript1(){ <br>
cat > $1 << "EOF"<br>
options(echo = TRUE)<br>
require(spgrass6)<br>
execGRASS("r.random", flags="overwrite", input="pnv_900m",
n="100", raster_output="test")<br>
EOF<br>
}<br>
RGRASSSCRIPT1="`g.tempfile pid=$$`"<br>
writeScript1 "$RGRASSSCRIPT1"<br>
R --no-save --no-restore --no-site-file --no-init-file <
$RGRASSSCRIPT1 > $LOGFILE 2>&1</font><tt><br>
</tt><br>
A small part of the logfile looks like:<br>
<br>
<font face="Courier New, Courier, monospace">> options(echo =
TRUE)<br>
> require(spgrass6)<br>
Loading required package: spgrass6<br>
Loading required package: sp<br>
Loading required package: XML<br>
GRASS GIS interface loaded with GRASS version: GRASS 7.0.svn
(2013)<br>
and location: AEA<br>
> execGRASS("r.random", flags="overwrite", input="pnv_900m",
n="100", raster_output="test")<br>
Collecting Stats...<br>
0% 3% 6% 9% 12% 15%
19% 22% 25% 28% 31% 34%
38% 41% 44% 47% 50% 53%
57% 60% 63% 66% 69% 73%
76% 79% 82% 85% 88% 92%
95% 98% 100%<br>
Writing raster map <test> ...<br>
0% 3% 6% 9% 12% 15%
18% 21% 24% 27% 30% 33%
36% 39% 42% 45% 48% 51%
54% 57% 60% 63% 66% 69%
72% 75% 78% 81% 84% 87%
90% 93% 96% 99% 100%<br>
> save.image(file="testing.RData")<br>
> options(echo = TRUE)<br>
> require(spgrass6)<br>
> execGRASS("r.random", flags="overwrite", input="pnv_900m",
n="100", raster_output="test")<br>
Collecting Stats...<br>
0% 3% 6% 9% 12% 15%
19% 22% 25% 28% 31% 34%
38% 41% 44% 47% 50% 53%
57% 60% 63% 66% 69% 73%
76% 79% 82% 85% 88% 92%
95% 98% 100%<br>
Writing raster map <AAAtestrandom1> ...<br>
0% 3% 6% 9% 12% 15%
18% 21% 24% 27% 30% 33%
36% 39% 42% 45% 48% 51%
54% 57% 60% 63% 66% 69%
72% 75% 78% 81% 84% 87%
90% 93% 96% 99% 100%<br>
> save.image(file="testing.RData")<br>
> options(echo = TRUE)<br>
.<br>
.<br>
etc..</font><br>
<br>
As you can see, after creating the random layer, it starts the
script again (line 14). It only happens, it seems, when using
execGRASS to run the r.random function (or use a direct system
call). Using execGRASS with any other function work fine it seems.<br>
<br>
I am not sure this is a problem with GRASS GIS, R, or what, but let
me first try the GRASS GIS email list. Any idea what could go wrong
here?<br>
<br>
Cheers,<br>
<br>
Paulo<br>
<br>
<br>
<br>
</body>
</html>