[GRASS-user] Previewing column names in input ASCII file without messing g.parser up

Hi there,

Working on windows 7, I was trying to run a GRASS bash shell script (written for the Cygwin version of GRASS) using the WinGRASS-6.4.SVN-r42329-1 installed from <http://josef.fsv.cvut.cz/wingrass/&gt;\. After some tuning to adopt the direct rendering approach and to adjust to msys pathname conventions, all runs fine (winGRASS is in "Program Files" and no problems occur using a variety of grass and shell commands) except for one feature of the script that I am not able to reproduce in the native winGRASS version.

The shell script basically imports (v.in.ascii) an ASCII text file with columns including latitude, longitude, and some variables, and then maps a variable of choice. It calls a little Perl script that prints column order and names before g.parser is called. In the Cygwin version, this results in (1) the output of the Perl script to be printed to the GRASS/bash terminal, and (2) the script GUI to be launched as well. This way, the user can look at names/numbers of columns in the ASCII file, and input column numbers of choice in the GUI for v.in.ascii.

In winGRASS, the execution of the Perl script that prints column names/numbers prevents the GUI of the main shell script from starting up when called in the Cmd> text box of the Python wxgui (started using the shortcut created by the installer), with the following error message in the command output tab:

    self.goutput.RunCmd(cmd, switchPage=False)
      File "C:\Program
    Files\GRASS-64-SVN\etc\wxpython\gui_modules\goutput.py",
    line 354, in RunCmd

    menuform.GUI().ParseCommand(cmdlist, parentframe=self)
      File "C:\Program
    Files\GRASS-64-SVN\etc\wxpython\gui_modules\menuform.py",
    line 1853, in ParseCommand

    handler)
      File "C:\OSGeo4W\apps\Python25\lib\xml\sax\__init__.py",
    line 49, in parseString

    parser.parse(inpsrc)
      File
    "C:\OSGeo4W\apps\Python25\lib\xml\sax\expatreader.py", line
    107, in parse

    xmlreader.IncrementalParser.parse(self, source)
      File "C:\OSGeo4W\apps\Python25\lib\xml\sax\xmlreader.py",
    line 123, in parse

    self.feed(buffer)
      File
    "C:\OSGeo4W\apps\Python25\lib\xml\sax\expatreader.py", line
    211, in feed

    self._err_handler.fatalError(exc)
      File "C:\OSGeo4W\apps\Python25\lib\xml\sax\handler.py",
    line 38, in fatalError

    raise exception
    xml.sax._exceptions
    .
    SAXParseException
    :
    <unknown>:2:0: syntax error

However, when calling the shell script in winGRASS text mode (started using the shortcut created by the installer) the Cygwin behavior is reproduced, i.e. column numbers and names are printed to the DOS terminal by the Perl script, and the GUI of the main shell script is launched as well. Apparently, this is due to the wxpython not having a DOS prompt where to print. Also, it seems to be calling code from OSGeo4W although I have checked my %PATH% environment variable, and there does not seem to be any reference to the C:\OSGeo4W installation: typing

    path | FINDSTR OSGeo4W

at the DOS prompt returns nothing.

Does anybody see a way around the wxpython problem that would allow column number/names in the input ASCII file to be previewed without preventing the g.parser GUI to start up?

A side note: it seems like the /scripts/ folder is not accessible inside custom shell scripts so that I had to add

    @set PATH=%GISBASE%\scripts\;%PATH%

in the corresponding .bat file that lives inside GISBASE/bin/ and is used to call the custom script itself from wxpython gui. Not sure why this happens.

Finally, I wanted to thank authors of posts from which I have collected info that enabled me to port shell scripts to native winGRASS (e.g. Glynn Clements and Elena Mitasova).

Kind regards and sorry for a long post of somewhat mixed content,

Luigi