[GRASS-dev] v.type.sh question - important for 6.4 release

Because the way that v.type works makes it unusable in a GUI, Hamish wrote a script wrapper that DOES work in the GUI. Logically, it is placed in $GISBASE/etc/gui/scripts.

However, windows cannot execute it there. I'm not sure if it is because it needs to have a *.exe put on the end or because it DOES have a *.exe and the GUI doesn't reference it correctly. I'm not sure if it just needs to be renamed (i.e., drop the .sh), or moved to the main $GISBASE/script directory, or what. But I bet that it is pretty easy to fix this for windows. I just don't know what to do.

If someone could offer advice, I could get it working for the 6.4 release.

Michael

Michael Barton wrote:

Because the way that v.type works makes it unusable in a GUI, Hamish
wrote a script wrapper that DOES work in the GUI. Logically, it is
placed in $GISBASE/etc/gui/scripts.

However, windows cannot execute it there. I'm not sure if it is
because it needs to have a *.exe put on the end or because it DOES
have a *.exe and the GUI doesn't reference it correctly. I'm not sure
if it just needs to be renamed (i.e., drop the .sh), or moved to the
main $GISBASE/script directory, or what. But I bet that it is pretty
easy to fix this for windows. I just don't know what to do.

If someone could offer advice, I could get it working for the 6.4
release.

The way that we normally make shell scripts work on Windows is to
provide a .bat file which explicitly invokes the script via $GRASS_SH.

On Windows, the $GISBASE/bin directory will contain a .bat file for
each script in the $GISBASE/scripts directory. These are created using
the scripts/windows_launch.bat file as a template.

It may suffice to add $GISBASE/etc/gui/scripts/v.type.sh.bat. If that
doesn't work, add an "if windows ..." case to gis.m's "execute"
function, which invokes the script via $env(GRASS_SH).

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

On Mar 11, 2009, at 4:23 AM, Glynn Clements wrote:

Michael Barton wrote:

Because the way that v.type works makes it unusable in a GUI, Hamish
wrote a script wrapper that DOES work in the GUI. Logically, it is
placed in $GISBASE/etc/gui/scripts.

However, windows cannot execute it there. I'm not sure if it is
because it needs to have a *.exe put on the end or because it DOES
have a *.exe and the GUI doesn't reference it correctly. I'm not sure
if it just needs to be renamed (i.e., drop the .sh), or moved to the
main $GISBASE/script directory, or what. But I bet that it is pretty
easy to fix this for windows. I just don't know what to do.

If someone could offer advice, I could get it working for the 6.4
release.

The way that we normally make shell scripts work on Windows is to
provide a .bat file which explicitly invokes the script via $GRASS_SH.

On Windows, the $GISBASE/bin directory will contain a .bat file for
each script in the $GISBASE/scripts directory. These are created using
the scripts/windows_launch.bat file as a template.

It may suffice to add $GISBASE/etc/gui/scripts/v.type.sh.bat. If that
doesn't work, add an "if windows ..." case to gis.m's "execute"
function, which invokes the script via $env(GRASS_SH).

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

This sounds good. Two questions.

1) How can we get the *.bat files to be generated for files in the $GISBASE/ext/gui/scripts folder?
2) Can v.type.sh.bat be called by just specifying v.type.sh? Or do you need to fully specify the *.bat extension?

Thanks
Michael

Michael Barton wrote:

>> Because the way that v.type works makes it unusable in a GUI, Hamish
>> wrote a script wrapper that DOES work in the GUI. Logically, it is
>> placed in $GISBASE/etc/gui/scripts.
>>
>> However, windows cannot execute it there. I'm not sure if it is
>> because it needs to have a *.exe put on the end or because it DOES
>> have a *.exe and the GUI doesn't reference it correctly. I'm not sure
>> if it just needs to be renamed (i.e., drop the .sh), or moved to the
>> main $GISBASE/script directory, or what. But I bet that it is pretty
>> easy to fix this for windows. I just don't know what to do.
>>
>> If someone could offer advice, I could get it working for the 6.4
>> release.
>
> The way that we normally make shell scripts work on Windows is to
> provide a .bat file which explicitly invokes the script via $GRASS_SH.
>
> On Windows, the $GISBASE/bin directory will contain a .bat file for
> each script in the $GISBASE/scripts directory. These are created using
> the scripts/windows_launch.bat file as a template.
>
> It may suffice to add $GISBASE/etc/gui/scripts/v.type.sh.bat. If that
> doesn't work, add an "if windows ..." case to gis.m's "execute"
> function, which invokes the script via $env(GRASS_SH).
>
> --
> Glynn Clements <glynn@gclements.plus.com>

This sounds good. Two questions.

1) How can we get the *.bat files to be generated for files in the
$GISBASE/ext/gui/scripts folder?

For the scripts in the scripts directory, this is done via the
following rule from Script.make:

$(BIN)/$(PGM).bat: $(MODULE_TOPDIR)/scripts/windows_launch.bat
  sed -e "s#SCRIPT_NAME#$(PGM)#" $(MODULE_TOPDIR)/scripts/windows_launch.bat > $@

For the gui/scripts, the above rule can be generalised to a pattern rule:

$(GISBASE)/etc/gui/scripts/%.bat: $(MODULE_TOPDIR)/scripts/windows_launch.bat
  sed -e "s#SCRIPT_NAME#$*#" $(MODULE_TOPDIR)/scripts/windows_launch.bat > $@

You then need to "make" the relevant .bat files with e.g.:

  for file in *.* ; do $(MAKE) $(GISBASE)/etc/gui/scripts/$$file.bat ; done

2) Can v.type.sh.bat be called by just specifying v.type.sh? Or do you
need to fully specify the *.bat extension?

Just using the base name seems to work for everything else, although I
can't exclude the possibility that Tcl behaves differently depending
upon whether a full path is used (it's actually Tcl which tries the
.exe and .bat suffixes; it doesn't use Windows' ShellExecute()).

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

On Mar 11, 2009, at 12:10 PM, Glynn Clements wrote:

The way that we normally make shell scripts work on Windows is to
provide a .bat file which explicitly invokes the script via $GRASS_SH.

On Windows, the $GISBASE/bin directory will contain a .bat file for
each script in the $GISBASE/scripts directory. These are created using
the scripts/windows_launch.bat file as a template.

It may suffice to add $GISBASE/etc/gui/scripts/v.type.sh.bat. If that
doesn't work, add an "if windows ..." case to gis.m's "execute"
function, which invokes the script via $env(GRASS_SH).

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

This sounds good. Two questions.

1) How can we get the *.bat files to be generated for files in the
$GISBASE/ext/gui/scripts folder?

For the scripts in the scripts directory, this is done via the
following rule from Script.make:

$(BIN)/$(PGM).bat: $(MODULE_TOPDIR)/scripts/windows_launch.bat
  sed -e "s#SCRIPT_NAME#$(PGM)#" $(MODULE_TOPDIR)/scripts/windows_launch.bat > $@

For the gui/scripts, the above rule can be generalised to a pattern rule:

$(GISBASE)/etc/gui/scripts/%.bat: $(MODULE_TOPDIR)/scripts/windows_launch.bat
  sed -e "s#SCRIPT_NAME#$*#" $(MODULE_TOPDIR)/scripts/windows_launch.bat > $@

You then need to "make" the relevant .bat files with e.g.:

  for file in *.* ; do $(MAKE) $(GISBASE)/etc/gui/scripts/$$file.bat ; done

2) Can v.type.sh.bat be called by just specifying v.type.sh? Or do you
need to fully specify the *.bat extension?

Just using the base name seems to work for everything else, although I
can't exclude the possibility that Tcl behaves differently depending
upon whether a full path is used (it's actually Tcl which tries the
.exe and .bat suffixes; it doesn't use Windows' ShellExecute()).

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

If someone who knows the build system well can make the changes Glynn recommended to Script.make, we can test to see if that does the trick. If not, I can change try to conditionalize the TclTk call for windows to find v.type.sh.bat.

(related question, is such a name permitted for Windows XP and Vista?)

Michael

Michael Barton wrote:

>> 1) How can we get the *.bat files to be generated for files in the
>> $GISBASE/ext/gui/scripts folder?
>
> For the scripts in the scripts directory, this is done via the
> following rule from Script.make:
>
> $(BIN)/$(PGM).bat: $(MODULE_TOPDIR)/scripts/windows_launch.bat
> sed -e "s#SCRIPT_NAME#$(PGM)#" $(MODULE_TOPDIR)/scripts/windows_launch.bat > $@
>
> For the gui/scripts, the above rule can be generalised to a pattern
> rule:
>
> $(GISBASE)/etc/gui/scripts/%.bat: $(MODULE_TOPDIR)/scripts/windows_launch.bat
> sed -e "s#SCRIPT_NAME#$*#" $(MODULE_TOPDIR)/scripts/windows_launch.bat > $@
>
> You then need to "make" the relevant .bat files with e.g.:
>
> for file in *.* ; do $(MAKE) $(GISBASE)/etc/gui/scripts/$$file.bat ; done

If someone who knows the build system well can make the changes Glynn
recommended to Script.make, we can test to see if that does the trick.

The changes should be made in gui/scripts/Makefile, not Script.make.

If not, I can change try to conditionalize the TclTk call for windows
to find v.type.sh.bat.

(related question, is such a name permitted for Windows XP and Vista?)

AFAIK, there is no restriction on having dots within a filename. Only
the final extension (the part after the last dot) is significant to
Windows.

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