[GRASS-user] Batch Processing in GRASS 6.2 w/ Cygwin

Glynn Clements glynn at gclements.plus.com
Wed Aug 8 16:05:11 EDT 2007

Steve Hanser wrote:

> I am trying to write a batch file for Cygwin that will run multiple GRASS 
> r.le.pixel commands, change the region, and rerun commands on the new 
> region.  I have a simplified version based on a previous posting to this 
> listserv.  I have tried using it under #!/bin/sh and #!/bin/ash and 
> receive error with both.  Please help.  Thank you.
> Under #!/bin/sh  -  Does not produce the testing.txt file
> $ ./batch-grass6v3.sh
> : No such file or directory4: testing.txt
> : No such file or directory5: testing.txt
> : No such file or directory6: testing.txt
> ': not a valid identifier 21: export: `GISBASE
> ': not a valid identifier 22: export: `GISRC
> ./batch-grass6v3.sh: line 25: $'g.version\r': command not found
> /etc/clean_temp: No such file or directoryrass-6.2.2

Your script appears to be using CRLF line termination; you need to use
LF (the CR will be treated literally, causing all kinds of errors).

This rules out using Notepad to edit scripts. Cygwin has packages for
vim, emacs and xemacs.

> Under #!/bin/ash
> Produces the testing.txt file but nothing else.
> $ ./batch-grass6v3.sh
> export: Files/ATI: bad variable name
> g.version: not found
> Here is the current version of the script:

> GISRC="~/testing.txt"

The ~ character isn't expanded inside quotes. Use $HOME instead, i.e.:


> echo $GISDBASE > testing.txt

I suggest adding quotes here, i.e.

	echo "$GISDBASE" > testing.txt

> export PATH=$PATH:$GISBASE/bin:$GISBASE/scripts

I strongly suggest adding quotes here. This is probably where the
"Files/ATI" comes from (i.e. /cygdrive/c/Program Files/ATI gets split
at the space between Program and Files).

Glynn Clements <glynn at gclements.plus.com>

More information about the grass-user mailing list