[GRASS-dev] [GRASS GIS] #3418: "Launch Script (*.sh)" doesn't work on Windows

#3418: "Launch Script (*.sh)" doesn't work on Windows
----------------------------------+-------------------------
Reporter: kking009 | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.2.3
Component: Default | Version: 7.2.2
Keywords: shell script windows | CPU: Unspecified
Platform: MSWindows 7 |
----------------------------------+-------------------------
Grass dispatches the *.sh file to windows, but obviously windows is not
able to handle the bash script.
Applies to all V7.X Versions. On V6.X that was working!

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3418&gt;
GRASS GIS <https://grass.osgeo.org>

#3418: "Launch Script (*.sh)" doesn't work on Windows
--------------------------+----------------------------------
  Reporter: kking009 | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.3
Component: Default | Version: 7.2.2
Resolution: | Keywords: shell script windows
       CPU: Unspecified | Platform: MSWindows 7
--------------------------+----------------------------------

Comment (by hellik):

Replying to [ticket:3418 kking009]:
> Grass dispatches the *.sh file to windows, but obviously windows is not
able to handle the bash script.
> Applies to all V7.X Versions. On V6.X that was working!

I may note that it may be a won't fix.shell scripts aren't cross platform
compatible.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3418#comment:1&gt;
GRASS GIS <https://grass.osgeo.org>

#3418: "Launch Script (*.sh)" doesn't work on Windows
--------------------------+----------------------------------
  Reporter: kking009 | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.3
Component: Default | Version: 7.2.2
Resolution: | Keywords: shell script windows
       CPU: Unspecified | Platform: MSWindows 7
--------------------------+----------------------------------

Comment (by kking009):

On V6.X Grass-Shell-Script were working Cross-Platform! I suppose Grass
were handling them and they weren't dispatched to the OS.
If I copy/execute line by line my script to the Grass-Comamnd-Console,
Grass is able to "handle" my scripts.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3418#comment:2&gt;
GRASS GIS <https://grass.osgeo.org>

#3418: "Launch Script (*.sh)" doesn't work on Windows
--------------------------+----------------------------------
  Reporter: kking009 | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.3
Component: Default | Version: 7.2.2
Resolution: | Keywords: shell script windows
       CPU: Unspecified | Platform: MSWindows 7
--------------------------+----------------------------------

Comment (by hellik):

Replying to [comment:2 kking009]:
> On V6.X Grass-Shell-Script were working Cross-Platform! I suppose Grass
were handling them and they weren't dispatched to the OS.
> If I copy/execute line by line my script to the Grass-Comamnd-Console,
Grass is able to "handle" my scripts.

I mean it more generally,shell scripts aren't working on all operating
systems out of the box, unless you bundle extra bins with the software
(e.g. msys in winGRASS).

IIRC There is a GRASS_SHELL variable to set (have a look in manual and
wiki), but it's not really maintained anymore to have shell script support
in winGRASS 7, as python is all around on the most is.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3418#comment:3&gt;
GRASS GIS <https://grass.osgeo.org>

#3418: "Launch Script (*.sh)" doesn't work on Windows
--------------------------+----------------------------------
  Reporter: kking009 | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.3
Component: Default | Version: 7.2.2
Resolution: | Keywords: shell script windows
       CPU: Unspecified | Platform: MSWindows 7
--------------------------+----------------------------------

Comment (by hellik):

Replying to [comment:2 kking009]:
> On V6.X Grass-Shell-Script were working Cross-Platform! I suppose Grass
were handling them and they weren't dispatched to the OS.
> If I copy/execute line by line my script to the Grass-Comamnd-Console,
Grass is able to "handle" my scripts.

If you want simpy to execute some GRASS modules in a script, just put the
module commands in a batch file in the following structure (I've added
some notes in the wiki): e.g. myworkflow.bat

Rem set region to a raster

call g.region raster=yourraster

Rem calculate slope

call r.slope.aspect raste=yourraster slope=yourslope

Etc

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3418#comment:4&gt;
GRASS GIS <https://grass.osgeo.org>

#3418: "Launch Script (*.sh)" doesn't work on Windows
--------------------------+----------------------------------
  Reporter: kking009 | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.3
Component: Default | Version: 7.2.2
Resolution: | Keywords: shell script windows
       CPU: Unspecified | Platform: MSWindows 7
--------------------------+----------------------------------

Comment (by hellik):

Replying to [comment:3 hellik]:
> Replying to [comment:2 kking009]:
> > On V6.X Grass-Shell-Script were working Cross-Platform! I suppose
Grass were handling them and they weren't dispatched to the OS.
> > If I copy/execute line by line my script to the Grass-Comamnd-Console,
Grass is able to "handle" my scripts.
>
> I mean it more generally,shell scripts aren't working on all operating
systems out of the box, unless you bundle extra bins with the software
(e.g. msys in winGRASS).
>
> IIRC There is a GRASS_SHELL variable to set (have a look in manual and
wiki), but it's not really maintained anymore to have shell script support
in winGRASS 7, as python is all around on the most is.

in the [https://grass.osgeo.org/grass73/manuals/variables.html manual]:

{{{
GRASS_SH
     [shell scripts on Windows]
     path to bourne shell interpreter used to run shell scripts.
}}}

this variable can be set in the winGRASS startup batch file by e.g.

{{{
set GRASS_SH="C:\OSGeo4W64\apps\msys\bin\sh.exe"
}}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3418#comment:5&gt;
GRASS GIS <https://grass.osgeo.org>

#3418: "Launch Script (*.sh)" doesn't work on Windows
--------------------------+----------------------------------
  Reporter: kking009 | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.3
Component: Default | Version: 7.2.2
Resolution: | Keywords: shell script windows
       CPU: Unspecified | Platform: MSWindows 7
--------------------------+----------------------------------

Comment (by hellik):

Replying to [comment:4 hellik]:
> Replying to [comment:2 kking009]:
> > On V6.X Grass-Shell-Script were working Cross-Platform! I suppose
Grass were handling them and they weren't dispatched to the OS.
> > If I copy/execute line by line my script to the Grass-Comamnd-Console,
Grass is able to "handle" my scripts.
>
> If you want simpy to execute some GRASS modules in a script, just put
the module commands in a batch file in the following structure (I've added
some notes in the wiki): e.g. myworkflow.bat
>
> Rem set region to a raster
>
> call g.region raster=yourraster
>
> Rem calculate slope
>
> call r.slope.aspect raste=yourraster slope=yourslope
>
> Etc

for the record the wiki link:

https://grasswiki.osgeo.org/wiki/GRASS_and_bat-files_in_windows_console

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3418#comment:6&gt;
GRASS GIS <https://grass.osgeo.org>

#3418: "Launch Script (*.sh)" doesn't work on Windows
--------------------------+----------------------------------
  Reporter: kking009 | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.3
Component: Default | Version: 7.2.2
Resolution: | Keywords: shell script windows
       CPU: Unspecified | Platform: MSWindows 7
--------------------------+----------------------------------

Comment (by kking009):

I wasn't aware I can execute batch files from the "Grass Startup Console".
They work perfectly!
With the following command it is even possible to run batch files without
starting up Grass:

"%ProgramFiles%\QGIS 2.18\bin\Grass72.bat" --exec MyScript.bat
D:/myGrassData/MyLoc/MyMapset

Nice! For me its fine to close the issue..

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3418#comment:7&gt;
GRASS GIS <https://grass.osgeo.org>

#3418: "Launch Script (*.sh)" doesn't work on Windows
--------------------------+----------------------------------
  Reporter: kking009 | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.2.3
Component: Default | Version: 7.2.2
Resolution: worksforme | Keywords: shell script windows
       CPU: Unspecified | Platform: MSWindows 7
--------------------------+----------------------------------
Changes (by martinl):

* status: new => closed
* resolution: => worksforme

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3418#comment:8&gt;
GRASS GIS <https://grass.osgeo.org>

#3418: "Launch Script (*.sh)" doesn't work on Windows
--------------------------+----------------------------------
  Reporter: kking009 | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.2.3
Component: Default | Version: 7.2.2
Resolution: worksforme | Keywords: shell script windows
       CPU: Unspecified | Platform: MSWindows 7
--------------------------+----------------------------------

Comment (by hellik):

Replying to [comment:7 kking009]:
> I wasn't aware I can execute batch files from the "Grass Startup
Console". They work perfectly!
> With the following command it is even possible to run batch files
without starting up Grass:
>
> "%ProgramFiles%\QGIS 2.18\bin\Grass72.bat" --exec MyScript.bat
D:/myGrassData/MyLoc/MyMapset
>
> Nice! For me its fine to close the issue..

I've expanded the wiki with your example:

  https://grasswiki.osgeo.org/wiki/GRASS_and_bat-files_in_windows_console

please improve the wiki entry with your experience. thanks.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3418#comment:9&gt;
GRASS GIS <https://grass.osgeo.org>