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

Glynn Clements glynn at gclements.plus.com
Thu Aug 9 07:16:24 EDT 2007


Steve Hanser wrote:

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

If you just need to script GRASS commands, it's easier to just run a
script from within a GRASS session than to script the creation of the
session.

> GISBASE="/cygdrive/c/cygwin/usr/local/grass-6.2.2"

This probably won't harm anything, but it's better to use Cygwin
pathnames for files and directories within the Cygwin hierarchy, i.e.:

	GISBASE="/usr/local/grass-6.2.2"

> # Generate Grass settings:
> #
> echo "GISDBASE: $GISDBASE
> LOCATION_NAME: newset
> MAPSET: PERMANENT" > $HOME/.grassrc6

Multi-line strings aren't robust; it's better to use either a
here-document:

	cat > "$HOME/.grassrc6" <<-EOF
	GISDBASE: $GISDBASE
	LOCATION_NAME: newset
	MAPSET: PERMANENT
	EOF

or a subshell:

	(
	echo "GISDBASE: $GISDBASE"
	echo "LOCATION_NAME: newset"
	echo "MAPSET: PERMANENT"
	) > "$HOME/.grassrc6"

or multiple commands appending to the file:

	echo "GISDBASE: $GISDBASE" > "$HOME/.grassrc6"
	echo "LOCATION_NAME: newset" >> "$HOME/.grassrc6"
	echo "MAPSET: PERMANENT" >> "$HOME/.grassrc6"

> export LD_LIBRARY_PATH=/cygdrive/c/cygwin/lib:$GISBASE/lib:$LD_LIBRARY_PATH

LD_LIBRARY_PATH is specific to Linux and SunOS/Solaris. Windows
(including Cygwin) uses PATH to located DLLs:

	export PATH="$GISBASE/lib:$PATH"

[Cygwin's DLLs are in its "bin" directory, which will already be in $PATH.]

It's probably the fact that $GISBASE/lib is missing from $PATH that's
preventing your script from working. If a Cygwin binary cannot find
its DLLs, it simply terminates without error.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-user mailing list