[GRASS-user] r.mapcalc in ssh session

Hi list,

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

both a and b maps exist, and the script runs as it should when using the GUI. I really can’t get my head around this one.

I found some reference to the problem in the archives, but it was all technical mambo jambo and it did not offer any solution to the problem (or not that I could figure out anyway).

Is there a solution or workaround for this problem because this severly limits the use of GRASS in my setup?

Kind regards,
Koen

Hi
r.mapcalculator …
JM Garijo


De: Hufkens Koen koen.hufkens@ua.ac.be
Para: grass-user@lists.osgeo.org
Enviado: domingo, 14 de diciembre, 2008 12:15:39
Asunto: [GRASS-user] r.mapcalc in ssh session

Hi list,

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

both a and b maps exist, and the script runs as it should when using the GUI. I really can’t get my head around this one.

I found some reference to the problem in the archives, but it was all technical mambo jambo and it did not offer any solution to the problem (or not that I could figure out anyway).

Is there a solution or workaround for this problem because this severly limits the use of GRASS in my setup?

Kind regards,
Koen

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@gclements.plus.com>