[GRASS-user] r.average with winGRASS

Eduardo Hdo. Izcara ehizcara at agrogex.com
Fri Nov 3 06:15:32 EST 2006


Thanks a lot, Paul, for your explanation.
At the moment I can’t apply your patch (I lack a cross-compiling environment to Windows), so I’ll wait for the modules to be fixed. For the time being, I think I’ll be able to bypass this problem.

Eduardo

>On Fri, 3 Nov 2006, Eduardo Hdo. Izcara wrote:
>
>> Hi all,
>>
>> I’m trying to run the command r.average with the Windows GRASS 6.3.x development version, nicely provided by Huidae Cho. I always obtain de message:
>>
>> “ERROR running r.stats command”
>>
>> No matter what the raster base and cover input are, the result is always the same.
>>
>> Does somebody know about some issue with the Windows versions of those commands? Of course, the Linux version works perfectly with the same arguments

>
>Yes, it was an issue with the module calling other modules using 
>G_system(). I expect there will be lots of issues like that with native 
>Windows GRASS, but they can be fixed. The patch included below fixes it 
>for now, but I don't want to apply it to CVS because (a) it isn't totally 
>correct, and it should convert the tempfile pathnames to Windows directory 
>separators - also it may depend on the shell being used - can you redirect 
>standard input from a file with cmd.exe? Perhaps you can and this is OK... 
>and (b) I'd rather find out why G_system() doesn't work than have to 
>change it to system() everywhere. But we'll get it working eventually.
>
>Paul
>
>Index: main.c
>===================================================================
>RCS file: /home/grass/grassrepository/grass6/raster/r.average/main.c,v
>retrieving revision 2.8
>diff -u -r2.8 main.c
>--- main.c      24 Sep 2006 17:44:00 -0000      2.8
>+++ main.c      3 Nov 2006 10:20:05 -0000
>@@ -89,9 +89,9 @@
>      tempfile1 = G_tempfile();
>      tempfile2 = G_tempfile();
>      G_message("%s:",STATS);
>-    sprintf (command, "%s -anC input='%s,%s' fs=space > %s",
>+    sprintf (command, "%s -anC input=\"%s,%s\" fs=space > \"%s\"",
>         STATS, basemap->answer, covermap->answer, tempfile1);
>-    if ((stat = G_system(command)))
>+    if ((stat = system(command)))
>      {
>         unlink(tempfile1);
>         G_fatal_error(_("%s: ERROR running %s command"), G_program_name(), 
>STATS
>);
>@@ -149,9 +149,9 @@
>      fclose (fd1);
>      fclose (fd2);
>      G_message("%s:",RECODE);
>-    sprintf (command, "%s input='%s' output='%s' < %s",
>+    sprintf (command, "%s input=%s output=%s < \"%s\"",
>         RECODE, basemap->answer, outputmap->answer, tempfile2);
>-    stat = G_system(command);
>+    stat = system(command);
>      unlink (tempfile1);
>      unlink (tempfile2);




More information about the grass-user mailing list