[GRASS-user] Seg fault with i.group in script

Hamish hamish_b at yahoo.com
Thu Dec 10 18:00:48 EST 2009


[sorry for to top post, yahoo mail is argh & I'm not taking the
time to rejustify it all by hand ....]


ok ok.


bourne/bash shell variables:

a variable name ends at the next space, period, or "quotation"
mark, but not at an underscore. if you want to have an underscore
after put the $var in curly brackets like ${band2}_corrected.
but "$band2"_corrected or "$band2.corrected" would work too.
note if you use 'single' quotes the $ is protected and the
variable name gets passed verbatim.

it is always a good idea to "quote" variables.

none of that should trigger a segfault though, it should just
give an error message. That will be a bug in the program, it
should handle invalid map names better.


Hamish



Ned wrote:
> Thanks for the debugging tips - they are helpful. It looks
> like it was a 
> problem with my variable names. I've been getting confused
> about when to 
> prefix the variable name with a "$". Dropping the "$" from
> the raster 
> names in i.group seems to have fixed the problem.
> 
> I have i.group working but now I realize there is another
> problem I need 
> to solve before the script will work. Slowly learning...
> 
> Ned
> 
> Hamish wrote:
> > try running with the --verbose flag turned on.
> > also `g.gisenv set="DEBUG=5"`  (set back to 0 to
> turn them off)
> >
> > can you change the top line of the shell script to be
> > #!/bin/sh -x
> >
> > then you can follow the exact expansion of the shell
> variables
> > from among the debug noise.
> >
> > probably python/bourne shell makes no difference; the
> imagary
> > library is not as robust as the raster one.
> >
> > perhaps the band name is very long? only recently have
> a lot
> > of the i.* modules been updated to deal with that.
> Looks like
> > that was a year ago so should be ok in 6.4.0rc5.
> >
> >
> > make sure there are no @mapset in the map names.
> >
> > ...?
> >
> >
> > Hamish
> >
> >
> >
> >
> > Ned wrote:
> >   
> >> Hi - I have a script that uses
> >> i.group to group 6 bands but when it runs I get a
> >> Segmentation fault. If I run the same i.group
> command
> >> (without "$") in the terminal it works just fine.
> This is
> >> the i.group command I am using in the script:
> >>
> >> i.group group=allBands subgroup=allBandSub
> >>
> input=$band1_corrected,$band2_corrected,$band3_corrected,
> >>
> $band4_corrected,$band5_corrected,$band6_corrected
> >>
> >> Is there anything obviously wrong? I am running
> this on
> >> Ubuntu using GRASS 6.4.0 RC5
> >>
> >> Would it make a difference if I converted the
> script to
> >> Python? I want to start learning how to write
> Python scripts
> >> and perhaps this is the time to learn.



      


More information about the grass-user mailing list