[GRASS-dev] [GRASS GIS] #2314: output r.out.xyz
GRASS GIS
trac at osgeo.org
Sat May 31 18:48:46 PDT 2014
#2314: output r.out.xyz
-------------------------------------------------+--------------------------
Reporter: pvanbosgeo | Owner: grass-dev@…
Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Keywords: separator, pipe, r.out.xyz, r.stats | Platform: MSWindows 7
Cpu: All |
-------------------------------------------------+--------------------------
Comment(by glynn):
Replying to [comment:18 annakrat]:
> > If a command is executed via e.g. grass.run_command(), Python's
subprocess.Popen() provides the necessary quoting.
>
> Apparently not.
Er, sort of. It quotes it, but the shell interprets | (and < and >) even
when quoted.
{{{
>>> subprocess.call(["args.exe","hello","world","|"])
argc = 4
argv[ 0] = 'args.exe'
argv[ 1] = 'hello'
argv[ 2] = 'world'
argv[ 3] = '|'
0
>>> subprocess.call(["args.exe","hello","world","|"],shell=True)
The syntax of the command is incorrect.
1
}}}
Without shell=True, the command must be an exe or batch file:
{{{
>>> subprocess.call(["args.exe","hello","world"])
argc = 3
argv[ 0] = 'args.exe'
argv[ 1] = 'hello'
argv[ 2] = 'world'
0
>>> subprocess.call(["args.bat","hello","world"])
C:\Users\Glynn>args.exe hello world
argc = 3
argv[ 0] = 'args.exe'
argv[ 1] = 'hello'
argv[ 2] = 'world'
0
>>> subprocess.call(["args.py","hello","world"])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files (x86)\Python27\lib\subprocess.py", line 493, in
call
return Popen(*popenargs, **kwargs).wait()
File "C:\Program Files (x86)\Python27\lib\subprocess.py", line 679, in
__init__
errread, errwrite)
File "C:\Program Files (x86)\Python27\lib\subprocess.py", line 893, in
_execute_child
startupinfo)
WindowsError: [Error 193] %1 is not a valid Win32 application
}}}
Currently, grass.Popen() sets shell=True for Windows, so that executing
scripts works.
It's looking as if we'll need to change that, and require the use of batch
files for executing scripts (however, I think that will have its own
problems if any of the arguments contain |, < or >).
--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2314#comment:25>
GRASS GIS <http://grass.osgeo.org>
More information about the grass-dev
mailing list