[GRASS-dev] [GRASS GIS] #1101: WinGrass7 + scripts are not found in the command line

#1101: WinGrass7 + scripts are not found in the command line
-------------------------------+--------------------------------------------
Reporter: hellik | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Packaging | Version: svn-trunk
Keywords: wingrass, scripts | Platform: MSWindows Vista
      Cpu: Unspecified |
-------------------------------+--------------------------------------------
Hi,

a in the osgeo4w-tree self compiled and NSIS-packaged and -installed
Wingrass7 (r42681)

starting WinGrass7 with the "GRASS 7.0.SVN with MSYS"-desktop-shortcut.

in the wx-gui-commandline all exe's(living in C:\Program
Files\GRASS-70-SVN\bin) and scripts (living in C:\Program
Files\GRASS-70-SVN\scripts) are found.

if i want to start a script (living in C:\Program
Files\GRASS-70-SVN\scripts) in the msys-windows-command-line, the scripts
are not found (see messages below or attached screenshot):

{{{
GRASS 7.0.svn> r.flow
GRASS 7.0.svn> r.covar
GRASS 7.0.svn> g.manual
sh.exe": g.manual: command not found
GRASS 7.0.svn> r.grow
sh.exe": r.grow: command not found
GRASS 7.0.svn> r.in.wms
sh.exe": r.in.wms: command not found
GRASS 7.0.svn>
}}}

Helmut

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

#1101: WinGrass7 + scripts are not found in the command line
-------------------------------+--------------------------------------------
Reporter: hellik | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Packaging | Version: svn-trunk
Keywords: wingrass, scripts | Platform: MSWindows Vista
      Cpu: Unspecified |
-------------------------------+--------------------------------------------

Old description:

Hi,

a in the osgeo4w-tree self compiled and NSIS-packaged and -installed
Wingrass7 (r42681)

starting WinGrass7 with the "GRASS 7.0.SVN with MSYS"-desktop-shortcut.

in the wx-gui-commandline all exe's(living in C:\Program
Files\GRASS-70-SVN\bin) and scripts (living in C:\Program
Files\GRASS-70-SVN\scripts) are found.

if i want to start a script (living in C:\Program
Files\GRASS-70-SVN\scripts) in the msys-windows-command-line, the scripts
are not found (see messages below or attached screenshot):

{{{
GRASS 7.0.svn> r.flow
GRASS 7.0.svn> r.covar
GRASS 7.0.svn> g.manual
sh.exe": g.manual: command not found
GRASS 7.0.svn> r.grow
sh.exe": r.grow: command not found
GRASS 7.0.svn> r.in.wms
sh.exe": r.in.wms: command not found
GRASS 7.0.svn>
}}}

Helmut

New description:

{{{
GRASS 7.0.svn> g.manual
sh.exe": g.manual: command not found
}}}

The spurious " is strange... maybe a quoting issue?

--

Comment(by neteler):

Replying to [ticket:1101 hellik]:
> Hi,
>
> a in the osgeo4w-tree self compiled and NSIS-packaged and -installed
Wingrass7 (r42681)
>
> starting WinGrass7 with the "GRASS 7.0.SVN with MSYS"-desktop-shortcut.
>
> in the wx-gui-commandline all exe's(living in C:\Program
Files\GRASS-70-SVN\bin) and scripts (living in C:\Program
Files\GRASS-70-SVN\scripts) are found.
>
> if i want to start a script (living in C:\Program
Files\GRASS-70-SVN\scripts) in the msys-windows-command-line, the scripts
are not found (see messages below or attached screenshot):
>
> {{{
> GRASS 7.0.svn> r.flow
> GRASS 7.0.svn> r.covar
> GRASS 7.0.svn> g.manual
> sh.exe": g.manual: command not found
> GRASS 7.0.svn> r.grow
> sh.exe": r.grow: command not found
> GRASS 7.0.svn> r.in.wms
> sh.exe": r.in.wms: command not found
> GRASS 7.0.svn>
> }}}
>
> Helmut

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

#1101: WinGrass7 + scripts are not found in the command line
-------------------------------+--------------------------------------------
Reporter: hellik | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Packaging | Version: svn-trunk
Keywords: wingrass, scripts | Platform: MSWindows Vista
      Cpu: Unspecified |
-------------------------------+--------------------------------------------

Comment(by glynn):

Replying to [ticket:1101 hellik]:

It appears that Markus edited the description rather than replying. Can
you delete this and open a new ticket?

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

#1101: WinGrass7 + scripts are not found in the command line
-------------------------------+--------------------------------------------
Reporter: hellik | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Packaging | Version: svn-trunk
Keywords: wingrass, scripts | Platform: MSWindows Vista
      Cpu: Unspecified |
-------------------------------+--------------------------------------------

Old description:

{{{
GRASS 7.0.svn> g.manual
sh.exe": g.manual: command not found
}}}

The spurious " is strange... maybe a quoting issue?

New description:

Hi,

a in the osgeo4w-tree self compiled and NSIS-packaged and -installed
  Wingrass7 (r42681)

starting WinGrass7 with the "GRASS 7.0.SVN with MSYS"-desktop-shortcut.

in the wx-gui-commandline all exe's(living in C:\Program
  Files\GRASS-70-SVN\bin) and scripts (living in C:\Program
  Files\GRASS-70-SVN\scripts) are found.

if i want to start a script (living in C:\Program
  Files\GRASS-70-SVN\scripts) in the msys-windows-command-line, the scripts
  are not found (see messages below or attached screenshot):

  {{{
  GRASS 7.0.svn> r.flow
  GRASS 7.0.svn> r.covar
  GRASS 7.0.svn> g.manual
  sh.exe": g.manual: command not found
  GRASS 7.0.svn> r.grow
  sh.exe": r.grow: command not found
  GRASS 7.0.svn> r.in.wms
  sh.exe": r.in.wms: command not found
  GRASS 7.0.svn>
  }}}

  Helmut

--

Comment(by neteler):

Replying to [ticket:1101 hellik]:
> {{{
> GRASS 7.0.svn> g.manual
> sh.exe": g.manual: command not found
> }}}
>
> The spurious " is strange... maybe a quoting issue?

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

#1101: WinGrass7 + scripts are not found in the command line
-------------------------------+--------------------------------------------
Reporter: hellik | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Packaging | Version: svn-trunk
Keywords: wingrass, scripts | Platform: MSWindows Vista
      Cpu: Unspecified |
-------------------------------+--------------------------------------------

Comment(by neteler):

{{{
  GRASS 7.0.svn> g.manual
  sh.exe": g.manual: command not found
  }}}

  The spurious " is strange... maybe a quoting issue?

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

#1101: WinGrass7 + scripts are not found in the command line
-------------------------------+--------------------------------------------
Reporter: hellik | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Packaging | Version: svn-trunk
Keywords: wingrass, scripts | Platform: MSWindows Vista
      Cpu: Unspecified |
-------------------------------+--------------------------------------------

Comment(by glynn):

Replying to [ticket:1101 hellik]:

{{{
GRASS 7.0.svn> g.manual
sh.exe": g.manual: command not found
}}}

Check the setting of `%GRASS_SH%`.

It should be set with something like:
{{{
set GRASS_SH=C:\msys\1.0\bin\sh.exe
}}}
or:
{{{
set GRASS_SH=C:\Program Files\GRASS-70-SVN\msys\1.0\bin\sh.exe
}}}
There shouldn't be any quotes, even if the filename contains spaces.

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

#1101: WinGrass7 + scripts are not found in the command line
-------------------------------+--------------------------------------------
Reporter: hellik | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Packaging | Version: svn-trunk
Keywords: wingrass, scripts | Platform: MSWindows Vista
      Cpu: Unspecified |
-------------------------------+--------------------------------------------

Comment(by hellik):

Replying to [comment:5 glynn]:
> Replying to [ticket:1101 hellik]:
>
> {{{
> GRASS 7.0.svn> g.manual
> sh.exe": g.manual: command not found
> }}}
>
> Check the setting of `%GRASS_SH%`.
>
> It should be set with something like:
> {{{
> set GRASS_SH=C:\msys\1.0\bin\sh.exe
> }}}
> or:
> {{{
> set GRASS_SH=C:\Program Files\GRASS-70-SVN\msys\1.0\bin\sh.exe
> }}}
> There shouldn't be any quotes, even if the filename contains spaces.

in grass70.bat, which invokes grass70.py, there is:
{{{
[...]
rem Set GRASS Installation Directory Variable
set GISBASE=C:\Program Files\GRASS-70-SVN
[...]
rem Path to the shell command
set GRASS_SH=%GISBASE%\msys\bin\sh.exe
}}}

and in the WinGrass7-command line:

{{{
GRASS 7.0.svn> echo $GRASS_SH
C:\Program Files\GRASS-70-SVN\msys\bin\sh.exe
GRASS 7.0.svn>
}}}

and sh.exe is in C:\Program Files\GRASS-70-SVN\msys\bin

Helmut

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

#1101: WinGrass7 + scripts are not found in the command line
-------------------------------+--------------------------------------------
Reporter: hellik | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Packaging | Version: svn-trunk
Keywords: wingrass, scripts | Platform: MSWindows Vista
      Cpu: Unspecified |
-------------------------------+--------------------------------------------

Comment(by hamish):

still broken?

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

#1101: WinGrass7 + scripts are not found in the command line
-------------------------------+--------------------------------------------
Reporter: hellik | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Packaging | Version: svn-trunk
Keywords: wingrass, scripts | Platform: MSWindows Vista
      Cpu: Unspecified |
-------------------------------+--------------------------------------------

Comment(by glynn):

Replying to [comment:7 hamish]:
> still broken?
7.0 no longer has any shell scripts, so this should be moot.

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

#1101: WinGrass7 + scripts are not found in the command line
-------------------------------+--------------------------------------------
Reporter: hellik | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Packaging | Version: svn-trunk
Keywords: wingrass, scripts | Platform: MSWindows Vista
      Cpu: Unspecified |
-------------------------------+--------------------------------------------

Comment(by hellik):

Replying to [comment:8 glynn]:
> Replying to [comment:7 hamish]:
> > still broken?
> 7.0 no longer has any shell scripts, so this should be moot.

tested with WinGRASS-7.0.SVN-r48376-1-Setup.exe

{{{ __________ ___ __________ _______________
          / ____/ __ \/ | / ___/ ___/ / ____/ _/ ___/
         / / __/ /_/ / /| | \__ \\_ \ / / __ / / \__ \
        / /_/ / _, _/ ___ |___/ /__/ / / /_/ // / ___/ /
        \____/_/ |_/_/ |_/____/____/ \____/___//____/

Welcome to GRASS 7.0.svn (2011)

GRASS homepage: http://grass.osgeo.org
This version running through: shell (C:\Program Files\GRASS
7.0.SVN\msys\bin\sh.exe)
Help is available with the command: g.manual -i
See the licence terms with: g.version -c
If required, restart the GUI with: g.gui wxpython
When ready to quit enter: exit

Launching 'wxpython' GUI in the background, please wait...
GRASS 7.0.svn> g.manual
sh.exe": g.manual: command not found
GRASS 7.0.svn> r.grow
sh.exe": r.grow: command not found
GRASS 7.0.svn> r.in.wms
sh.exe": r.in.wms: command not found
GRASS 7.0.svn> echo $GRASS_SH
C:\Program Files\GRASS 7.0.SVN\msys\bin\sh.exe
GRASS 7.0.svn> g.manual -ui
sh.exe": g.manual: command not found
GRASS 7.0.svn>
}}}

?
Helmut

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

#1101: WinGrass7 + scripts are not found in the command line
-------------------------------+--------------------------------------------
Reporter: hellik | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Packaging | Version: svn-trunk
Keywords: wingrass, scripts | Platform: MSWindows Vista
      Cpu: Unspecified |
-------------------------------+--------------------------------------------

Comment(by hellik):

Replying to [comment:9 hellik]:

better layout of the messages

{{{

           __________ ___ __________ _______________
          / ____/ __ \/ | / ___/ ___/ / ____/ _/ ___/
         / / __/ /_/ / /| | \__ \\_ \ / / __ / / \__ \
        / /_/ / _, _/ ___ |___/ /__/ / / /_/ // / ___/ /
        \____/_/ |_/_/ |_/____/____/ \____/___//____/

Welcome to GRASS 7.0.svn (2011)

GRASS homepage: http://grass.osgeo.org
This version running through: shell (C:\Program Files\GRASS
7.0.SVN\msys\bin\sh.exe)
Help is available with the command: g.manual -i
See the licence terms with: g.version -c
If required, restart the GUI with: g.gui wxpython
When ready to quit enter: exit

Launching 'wxpython' GUI in the background, please wait...
GRASS 7.0.svn> g.manual
sh.exe": g.manual: command not found
GRASS 7.0.svn> r.grow
sh.exe": r.grow: command not found
GRASS 7.0.svn> r.in.wms
sh.exe": r.in.wms: command not found
GRASS 7.0.svn> echo $GRASS_SH
C:\Program Files\GRASS 7.0.SVN\msys\bin\sh.exe
GRASS 7.0.svn> g.manual -ui
sh.exe": g.manual: command not found
GRASS 7.0.svn>

}}}

any hints to look why there seems to be tried invoking shell scripts
instead of the phytonized scripts in grass70svn?

Helmut

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

#1101: WinGrass7 + scripts are not found in the command line
-------------------------------+--------------------------------------------
Reporter: hellik | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Packaging | Version: svn-trunk
Keywords: wingrass, scripts | Platform: MSWindows Vista
      Cpu: Unspecified |
-------------------------------+--------------------------------------------

Comment(by glynn):

Replying to [comment:10 hellik]:

> any hints to look why there seems to be tried invoking shell scripts
instead of the pythonized scripts in grass70svn?

1. Does %PATH% contain the "scripts" directory?
2. Does PATHEXT include ".PY"?

!#2 isn't required for bash, which will recognise the "#!/usr/bin/env
python" lines provided that there's a Python interpreter in $PATH (which
shouldn't be the case, but probably is with the OSGeo4W setup). But
cmd.exe (and Python itself) will use the file associations for the .PY
extension (which Python will set up if it's installed correctly).

BTW, I believe that the "sh.exe" is because you're typing the commands
into the shell, not because something is trying to execute the command as
a shell script.

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

#1101: WinGrass7 + scripts are not found in the command line
-------------------------------+--------------------------------------------
Reporter: hellik | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Packaging | Version: svn-trunk
Keywords: wingrass, scripts | Platform: MSWindows Vista
      Cpu: Unspecified |
-------------------------------+--------------------------------------------

Comment(by martinl):

Replying to [comment:11 glynn]:
> Replying to [comment:10 hellik]:
  1. Does %PATH% contain the "scripts" directory?

yes,

  2. Does PATHEXT include ".PY"?

yes

When I type

{{{
g.manual
}}}

-> `command not found`

Of course

{{{
g.manual.py
}}}

works.

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

#1101: WinGrass7 + scripts are not found in the command line
-------------------------------+--------------------------------------------
Reporter: hellik | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Packaging | Version: svn-trunk
Keywords: wingrass, scripts | Platform: MSWindows Vista
      Cpu: Unspecified |
-------------------------------+--------------------------------------------

Comment(by glynn):

Replying to [comment:12 martinl]:

> > 2. Does PATHEXT include ".PY"?
>
> yes

> When I type
>
{{{
g.manual
}}}
>
> -> `command not found`
>
> Of course
>
{{{
g.manual.py
}}}
>
> works.

I'm forgetting that we're dealing with bash here. bash ignores PATHEXT,
and it doesn't use file extensions either (except perhaps .bat?).

OTOH, cmd.exe uses PATHEXT and file extensions but ignores the shebang.
And, on Windows, GRASS' G_spawn(), C's system() and Python's os.system()
and subprocess.Popen() all use cmd.exe, not bash.

If we want Python scripts to work in bash, I suspect that we'll need to
create shell-script wrappers without the .py extension which invoke the
script via e.g. $GRASS_PYTHON. Or just require users to type the ".py"
when running scripts from a shell. Or, if we're only interested in shells
which are started by GRASS, we can customise the .bashrc file to define
aliases for all of the Python scripts, e.g.:
{{{
alias g.manual='"$GRASS_PYTHON" "$GISBASE/scripts/g.manual.py"'
...
}}}

Ultimately, using bash on Windows is always going to be a pain; it's a
struggle just to achieve "adequate", and almost impossible to go beyond
that. But I don't know whether bash support really matters to actual
Windows users (as opposed to GRASS developers who are running WinGRASS
solely for testing purposes).

The priority should be to ensure that "native" support works, i.e.
invoking scripts from the GUI, cmd.exe, Python scripts and C programs.
Personally, I'd prefer it if Windows+bash support was limited to
information on the Wiki, so that users understand that it's a "use at your
own risk" feature.

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

#1101: WinGrass7 + scripts are not found in the command line
-------------------------------+--------------------------------------------
Reporter: hellik | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Packaging | Version: svn-trunk
Keywords: wingrass, scripts | Platform: MSWindows Vista
      Cpu: Unspecified |
-------------------------------+--------------------------------------------

Comment(by hellik):

Replying to [comment:13 glynn]:
>
> I'm forgetting that we're dealing with bash here. bash ignores PATHEXT,
and it doesn't use file extensions either (except perhaps .bat?).
>
> OTOH, cmd.exe uses PATHEXT and file extensions but ignores the shebang.
And, on Windows, GRASS' G_spawn(), C's system() and Python's os.system()
and subprocess.Popen() all use cmd.exe, not bash.
>

at the moment wingrass7 "GRASS 7.0.SVN with MSYS" is started in the
following way:

set_shell_start_grass70svn.bat is invoked

{{{

@echo off
rem
#########################################################################
rem #
rem # File dynamically created by NSIS installer script
rem #
rem
#########################################################################
rem #
rem # Set SHELL and start GRASS
rem #
rem
#########################################################################

rem *******Set SHELL***********

set SHELL="C:\Program Files\GRASS 7.0.SVN\msys\bin\sh.exe"

"C:\Program Files\GRASS 7.0.SVN\grass70svn.bat"

}}}

grass70svn.bat

{{{

@echo off
rem
#########################################################################
rem #
rem # File dynamically created by NSIS installer script;
rem #
rem
#########################################################################
rem #
rem # GRASS Initialization
rem #
rem
#########################################################################

rem Set GRASS Installation Directory Variable
set GISBASE=C:\Program Files\GRASS 7.0.SVN

set PATH=C:\Program Files\R\R-2.13.0\bin;%PATH%

call "%GISBASE%\etc\env.bat"

cd "%USERPROFILE%"
%GRASS_PYTHON% "%WINGISBASE%\grass70.py" %*

}}}

and a cmd.exe-windows is opened as command line and the wy-gui is starting

Helmut

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

#1101: WinGrass7 + scripts are not found in the command line
-------------------------------+--------------------------------------------
Reporter: hellik | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Packaging | Version: svn-trunk
Keywords: wingrass, scripts | Platform: MSWindows Vista
      Cpu: Unspecified |
-------------------------------+--------------------------------------------

Comment(by wenzeslaus):

See also:

  * #580 WinGRASS: $GISBASE/etc/gui/scripts/ require something like $(EXE)
to run
  * #1871 winGRASS 7: solve python distribution
  * #2138 winGRASS6.4.svn - addon python script status?
  * #2150 Cannot call Python scripts from Python on MS Windows
  * [http://lists.osgeo.org/pipermail/grass-dev/2013-October/065896.html
Handling of Python scripts on MS Windows]
  * [http://lists.osgeo.org/pipermail/grass-dev/2014-February/067373.html
Handling of Python scripts on MS Windows] (question how QGIS and OSGeo4W
works)
  * r54612 - source:grass/trunk/mswindows -
[http://lists.osgeo.org/pipermail//grass-dev/2013-January/061451.html
wingrass: attempt to define python file association]

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