Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#3418 closed defect (worksforme)

"Launch Script (*.sh)" doesn't work on Windows

Reported by: kking009 Owned by: grass-dev@…
Priority: normal Milestone: 7.2.3
Component: Default Version: 7.2.2
Keywords: shell script windows Cc:
CPU: Unspecified Platform: MSWindows 7

Description

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!

Change History (9)

in reply to:  description comment:1 by hellik, 7 years ago

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

comment:2 by kking009, 7 years ago

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.

in reply to:  2 ; comment:3 by hellik, 7 years ago

Replying to 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 reply to:  2 ; comment:4 by hellik, 7 years ago

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

in reply to:  3 comment:5 by hellik, 7 years ago

Replying to hellik:

Replying to 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 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"

in reply to:  4 comment:6 by hellik, 7 years ago

Replying to hellik:

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

comment:7 by kking009, 7 years ago

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

comment:8 by martinl, 7 years ago

Resolution: worksforme
Status: newclosed

in reply to:  7 comment:9 by hellik, 7 years ago

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

Note: See TracTickets for help on using tickets.