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

Steve Hanser shanser at usgs.gov
Wed Aug 8 19:04:13 EDT 2007


I need more help.  I implemented the suggestions from Glynn and edited the 
file in emacs.  I no longer receive any error messages but the script does 
not run any GRASS processes.  Here is the current version of the script. 
Obviously I am new to this so I appreciate any help I can get.  I have 
about 100 processes to complete and a batch script is the only way I think 
I'll get it done.  Thank you.

#!/bin/sh
#customize this:
#
GISRC="$HOME/.grassrc6"
GISDBASE="/cygdrive/c/Data/WBEA"
GISBASE="/cygdrive/c/cygwin/usr/local/grass-6.2.2"
# Generate Grass settings:
#
echo "GISDBASE: $GISDBASE
LOCATION_NAME: newset
MAPSET: PERMANENT" > $HOME/.grassrc6
#
# Exports
#
#
export 
LD_LIBRARY_PATH=/cygdrive/c/cygwin/lib:$GISBASE/lib:$LD_LIBRARY_PATH
export GISRC=$HOME/.grassrc6
export PATH="$PATH:$GISBASE/bin:$GISBASE/scripts"
export GIS_LOCK=$$
r.le.pixel map=bigsage sam=m att=b4 te1=m7 te2=t1,t2 edg=e1
#
# CleanupandExit
#
$GISBASE/etc/clean_temp
rm -rf /cygdrive/c/cygwin/tmp/grass6-$USER-$GIS_LOCK
rm -f $GISRC

Steve Hanser
Wildlife Biologist / GIS Specialist
USGS, FRESC, Snake River Field Station
970 Lusk St. Boise, ID 83706
PH: 208-426-2892 FAX: 208-426-5210

Steve Hanser
Wildlife Biologist / GIS Specialist
USGS, FRESC, Snake River Field Station
970 Lusk St. Boise, ID 83706
PH: 208-426-2892 FAX: 208-426-5210




Glynn Clements <glynn at gclements.plus.com> 
08/08/2007 02:05 PM

To
Steve Hanser <shanser at usgs.gov>
cc
grassuser at grass.itc.it
Subject
Re: [GRASS-user] Batch Processing in GRASS 6.2 w/ Cygwin







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.:

                 GISRC="$HOME/testing.txt"

> 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>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20070808/2db28418/attachment.html


More information about the grass-user mailing list