[GRASS-user] Running Scripts in GRASS

Hamish hamish_b at yahoo.com
Wed Aug 19 09:33:53 EDT 2009


Andrew wrote:
> for file in A*_MO_CHLO_4 ; do
>   echo "map: $file"
> 
>   gdal_translate -a_srs "+init=epsg:4326" -a_nodata 65535 \
>     -a_ullr -180 90 180 -90 -co "COMPRESS=PACKBITS" \
>     $file ${file}_prep.tif
> 
>   r.in.gdal in=${file}_prep.tif out=$file
> done
>
> Can anyone tell me the language the program is
> in?  I am not familiar with it and it would be good to
> know more about it.

The language is Bourne shell script; the terminal you get from
Applications/Utilities/Terminal is mostly likely running "Bash".

(try "echo $BASH_VERSION" from the terminal prompt to check; if your
user account was created by OSX 10.2 or earlier it is likely you are
using csh instead of bash there..)

Bourne shell scripting is the native language (if you can call it that)
of the Bash terminal. (Bash actually stands for Bourne Again SHell).

It lets you do fancy things at the terminal prompt like creating a loop
to run some command on all the data files in that directory, such as
the few lines above are doing.

The * is a wildcard; $file is the variable within the loop which sets
itself to each file name, runs the commands substituting as it goes for
each iteration of the for loop.

gdal_translate is a program for manipulating GeoTiffs etc which comes
with GDAL tools, r.in.gdal is the GRASS command for importing things
like GeoTiffs. echo just prints some text to the screen.


Hamish



      



More information about the grass-user mailing list