Opened 10 years ago

Closed 5 years ago

#1101 closed defect (fixed)

WinGrass7 + scripts are not found in the command line

Reported by: hellik Owned by: grass-dev@…
Priority: normal Milestone: 7.0.0
Component: Packaging Version: svn-trunk
Keywords: wingrass, scripts Cc:
CPU: Unspecified Platform: MSWindows Vista

Description (last modified by neteler)

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

Attachments (1)

WinGrass_scripts_30062010_225838.png (62.1 KB) - added by hellik 10 years ago.

Download all attachments as: .zip

Change History (17)

Changed 10 years ago by hellik

comment:1 in reply to:  description Changed 10 years ago by neteler

Description: modified (diff)

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

comment:2 in reply to:  description Changed 10 years ago by glynn

Replying to hellik:

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

comment:3 in reply to:  description Changed 10 years ago by neteler

Description: modified (diff)

Replying to hellik:

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

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

comment:4 Changed 10 years ago by neteler

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

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

comment:5 in reply to:  description ; Changed 10 years ago by glynn

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

comment:6 in reply to:  5 Changed 10 years ago by hellik

Replying to glynn:

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

comment:7 Changed 9 years ago by hamish

still broken?

comment:8 in reply to:  7 ; Changed 9 years ago by glynn

Replying to hamish:

still broken?

7.0 no longer has any shell scripts, so this should be moot.

comment:9 in reply to:  8 ; Changed 9 years ago by hellik

Replying to glynn:

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

comment:10 in reply to:  9 ; Changed 9 years ago by hellik

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

comment:11 in reply to:  10 ; Changed 9 years ago by glynn

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

comment:12 in reply to:  11 ; Changed 9 years ago by martinl

Replying to glynn:

Replying to hellik:

  1. Does %PATH% contain the "scripts" directory?

yes,

  1. Does PATHEXT include ".PY"?

yes When I type

g.manual

-> command not found

Of course

g.manual.py

works.

comment:13 in reply to:  12 ; Changed 9 years ago by glynn

Replying to martinl:

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

comment:14 in reply to:  13 Changed 9 years ago by hellik

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

comment:15 Changed 6 years ago by wenzeslaus

See also:

comment:16 in reply to:  15 Changed 5 years ago by hellik

Resolution: fixed
Status: newclosed

Replying to wenzeslaus:

See also:

tested with

System Info                                                                     
GRASS version: 7.0.3RC1                                                         
GRASS SVN Revision: 67443                                                       
Build Date: 2015-12-31                                                          
Build Platform: i386-w64-mingw32                                                
GDAL/OGR: 1.11.3                                                                
PROJ.4: 4.9.2                                                                   
GEOS: 3.5.0                                                                     
SQLite: 3.7.17                                                                  
Python: 2.7.4                                                                   
wxPython: 2.8.12.1                                                              
Platform: Windows-7-6.1.7601-SP1 (OSGeo4W)

it works; closing ticket.

Note: See TracTickets for help on using tickets.