[GRASS-windows] Running a bash script in Wingrass...

Glynn Clements glynn at gclements.plus.com
Wed Jul 23 16:02:01 EDT 2008


Jonathan Greenberg wrote:

> I have the latest and greatest wingrass installed, as well as 
> MSYS/MINGW, and I'm trying to figure out how, exactly, to launch a bash 
> script I've created (and successfully run) on a unix box.  From boot 
> time to actually calling the script, what is the order of ops?  I've 
> tried launching grass via the -text command, but typing the full path to 
> my .sh script once in grass just opens the script in a windows text 
> editor.  Help!

	C:\msys\1.0\bin\sh.exe script.sh

However that gets annoying quite quickly, so you can set:

	assoc .sh=shscript
	ftype shscript=c:\msys\1.0\bin\sh.exe %1

Then you can just type the name of the script (or the path, if it
isn't in the current directory). Also, you can use:

	set PATHEXT=%PATHEXT%;.sh

to avoid having to type the extension.

Also, you will probably need:

	set PATH=C:\msys\1.0\bin;%PATH%

so that the shell can find any MSys programs which are run from the
script.

Regardless of any configuration, using Unix shell scripts on Windows
has an inevitable nuisance factor associated with it (which is why
we're planning on largely eliminating the use of shell scripts in 7.0,
in favour of Python).

Every Windows port of a Unix shell which I have seen includes some
degree of Unix "emulation", which gets in the way if you try to
interface with Windows.

E.g. trying to impose Unix filename syntax. Shells need to do this
because the scripts which people want to run often include things like
"$dir/$file" (Unix / directory separator instead of Windows' \
separator). Also, $PATH uses : as the item separator, but Windows uses
that for the drive specifier.

So the shell uses a Unix-like syntax internally then translates
between the two as needed. Except that it can't always tell when it's
needed.

GRASS' Init.sh script gets bitten by this. Normally, you can run it
with a full path to the mapset directory to avoid the interactive
(curses or Tcl/Tk) startup screens. But if you do this with MSys, the
script uses the MSys syntax for the GISDBASE entry in the $GISRC file,
which doesn't work within GRASS itself. In this context, MSys' shell
doesn't recognise that it's a pathname which needs translation.

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


More information about the grass-windows mailing list