[GRASS-user] Re: grass-user Digest, Vol 27, Issue 58

Michael Barton michael.barton at asu.edu
Sat Jul 26 14:27:23 EDT 2008


On Jul 26, 2008, at 9:00 AM, <grass-user-request at lists.osgeo.org> <grass-user-request at lists.osgeo.org 
 > wrote:

> Date: Sat, 26 Jul 2008 12:17:05 -0300
> From: "Milton Cezar Ribeiro" <miltinho.astronauta at gmail.com>
> Subject: [GRASS-user] running script on Native Wingrass.
> To: grass-user at lists.osgeo.org
> Message-ID:
> 	<64f1583f0807260817v452d7c5obadf9b0478d48c4c at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Dear all,
>
> Sorry to write again on this issue, but I still need help on this.
>
> I installed Native WinGrass (on c:\GRASS directory) and
> GRASS_MSYS_Environment
> (on c:\GRASS_MSYS_Environment directory). Now I need to run a script  
> of
> grass
> commands, but I only know how to run one-by-one command. I really need
> some help (with a step-by-step advice) of how can I tell to Grass  
> (or GIS.m
> interface)
> to call my script file and run a sequence of commands.

1. Write a script in GRASS format
2. Put it into the GRASS scripts directory [path to grass]\scripts
3. Make sure that you have the proper permissions to run it (you  
probably do, but sometimes this is an issue)
4. Type the name of the script in the command window (at the bottom of  
the output screen) and press "run". If you just type the name, without  
any arguments, the script will open with a simple GUI that allows you  
to enter arguments and run it. If you type the name with arguments, it  
will run and do whatever it is supposed to do.

If you have never written scripts, there are tutorials on the GRASS  
WIKI for how to write them. Traditionally, scripts have been written  
in the bash shell scripting language because it usually comes  
preinstalled on many Linux/Unix systems. With MSys installed, you can  
use this language in Windows too. In addition to the WIKI, you can  
look at the many examples already in the GRASS scripts directory.

An overview of scripting can be found at: http://grass.osgeo.org/wiki/Scripting

However, I very much recommend that you try scripting with Python.  
This is an open source language that is more powerful and much easier  
to work with than bash shell scripts. It is also cross-platform with a  
binary version for Windows you can easily install from http://www.python.org 
.

Instructions for creating GRASS Python scripts can be found on the  
WIKI at: http://grass.osgeo.org/wiki/GRASS_and_Python. A document  
explaining GRASS scripting standards is available here: http://svn.osgeo.org/grass/grass/trunk/SUBMITTING_PYTHON 
. A new GRASS python library will soon be available to make this even  
easier.

Some information on the syntax to build the simple GUI for scripts if  
here: http://grass.ibiblio.org/grass63/manuals/html63_user/g.parser.html
But it is incomplete in that there are more options available than  
listed.

I recently ported a bash script I wrote some years ago to Python. You  
can see it here:
http://www.public.asu.edu/~cmbarton/files/grass_scripts/r_in_aster.py

I hope this is helpful.

Michael

>
>
> Kind regards,
>
> miltinho astronauta
> brazil



More information about the grass-user mailing list