[GRASSLIST:4778] Re: batch jobs

Glynn Clements glynn.clements at virgin.net
Fri Oct 18 04:26:15 EDT 2002


M.Wegmann wrote:

> first thanks a lot for your help, I managed to write my first bash
> script and it's working.....nearly ;-)
> 
> could it be, that I can't grab a file which is an output of a GRASS
> command?
> 
> eg (temp and $temp):
> 
> r.mapcalc "temp=int(raster*1000000)"
> 
> r.statistics base=killarney cover=$temp method=.... 
> 
> here it seems that it can't read the $temp file. error message is: "no
> cover map found". what would be a solution for that?

Omit the dollar sign. "$temp" refers to the contents of the shell
variable called "temp"; but there is no such variable, so you are
effectively running:

	r.statistics base=killarney cover= method=.... 

I.e. the value of the "cover=" parameter is empty.

You only use the dollar sign when you want to use the value of a
variable (e.g. from a "for" loop, a "read" statement etc).

> and another thing, I want to do a loop for all images starting with
> the letter b,d and t.
> 
> eg
> 
> for x in "[a,d,t]*"
> 
> do
> 
> .....
> r.mapcalc "temp=int($x*1000000)"
> ....
> 
> done
> 
> but that doesn't work. something wrong in the way I wrote it?

Omit the quotes, and the commas, i.e.

	for x in [adt]*

Filename "globbing" (replacing a pattern with all filenames which
match that pattern) isn't performed within quotes. However, variable
expansion (i.e. replacing $x with the value of x) is performed within
double quotes, but not within single quotes.

-- 
Glynn Clements <glynn.clements at virgin.net>



More information about the grass-user mailing list