[GRASS-user] r.mapcalc in ssh session
Glynn Clements
glynn at gclements.plus.com
Sun Dec 14 08:46:13 EST 2008
Hufkens Koen wrote:
> this weekend I ssh'd in computer to let some processes run in the
> background so I have my results tommorow.
>
> However my script crashes on a strange error related to r.mapcalc. I
> tried some r.mapcalc commands within the ssh'd GRASS session and I get
> the same error.
>
> for example:
>
> r.mapcalc amap=pnm bmap=pbl4 formula=A*B outfile=test --overwrite
> syntax error, unexpected NAME, expecting $end
> Parse error
The above syntax is valid for the r.mapcalculator script which is used
by gis.m, but not for r.mapcalc itself. You need to use either:
GRASS_OVERWRITE=1 r.mapcalc 'test = pnm*pbl4'
or:
r.mapcalculator amap=pnm bmap=pbl4 formula=A*B outfile=test --overwrite
In 6.4, r.mapcalc doesn't use the standard command-line parser, which
is part of the reason why r.mapcalculator exists and is used by gis.m.
In 7.0, r.mapcalc uses the command-line parser. This means that it
supports --help, --overwrite, --ui etc, but it also means that you
either have to specify the option name explicitly:
r.mapcalc expression='test=pnm*pbl4'
or at least provide the expression as a single argument, formattted so
that it doesn't get mistaken for an option by ensuring that there is a
space before the first = sign.
This will work in 7.0:
r.mapcalc expression=test=pnm*pbl4
This will work in both 7.0 and older versions:
r.mapcalc 'test = pnm*pbl4'
This won't work in 7.0:
r.mapcalc test=pnm*pbl4
(it will complain that r.mapcalc doesn't have an option named test=).
Nor will this:
r.mapcalc test = pnm*pbl4
(expressions can't be split over multiple arguments).
Also, feeding the expression via stdin will work in all versions,
e.g.:
echo "test = pnm*pbl4" | r.mapcalc
or:
r.mapcalc <<EOF
test = pnm*pbl4
EOF
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-user
mailing list