Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using a shell script that is called by a batch file. The shell script contains the GRASS scripts that I am using for my program. Every time I use the r.mask script, it displays the error r.mask: command not found.

Can r.mask be called from a batch file? How can I use r.mask using a batch file and shell script?

share|improve this question

A shell script called by a batch file? So you're running GRASS on a *nix box that is connected to a Windows box...

Either way, you need to ensure you have set up the environment correctly on whichever machine has GRASS installed. At the very least you need to ensure the PATH environment variable contains the directory in which the GRASS scripts can be found. On my Ubunutu machine, it's /usr/lib/grass64/scripts/ but your installation may be different.

See here for lots of useful information on setting up the GRASS environment and running shell scripts.

share|improve this answer
I already fixed my environment variables. My other scripts are working, except for the r.mask script – teamAngat Aug 7 '11 at 13:20
Hmmm... then I would be inclined to say it isn't there! If you're using Linux, type locate r.mask to see if it can find it, and you can also try locate with a script you know exists, and have a look in that directory. If you can't find it, then it's either been deleted, or you are running a version of GRASS that didn't come with that script, although I'm not sure if there are any versions like that. – MerseyViking Aug 7 '11 at 13:32
The script could run if I run it in grass itself, but when I run it using the batch file, it does not run. All my scripts run (, r.out.gdal, r.out.png, r.mapcalc, etc.) except for the r.mask. – teamAngat Aug 7 '11 at 15:18
The only difference I can see is that r.mask is a script, whereas the others are binaries, and so they live in a different place. So make sure you have the scripts directory added to your path. I'm on a SuSE box at the moment and the GRASS binaries are in /opt/grass/bin/, but the scripts are in /opt/grass/scripts/ If you can run it from within GRASS then it must be somewhere on your system, so it's just a case of finding it and adding that directory to your PATH. – MerseyViking Aug 8 '11 at 8:54

I understand that you work with winGRASS. If it is winGRASS 6, then try r.mask.bat or to call it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.