[GRASS-user] shell scripting problem

Kirk Wythers kirk.wythers at gmail.com
Thu Sep 13 07:04:29 PDT 2012


Thanks Stephen

I just found the problem… bloody meta character "^M" that did not show up in my text editor. I opened the coords file with vi and there it was!

krw


On Sep 13, 2012, at 9:00 AM, Stephen Sefick <sas0025 at auburn.edu> wrote:

> Are some of the data points missing?  That would be my first guess.
> HTH,
> 
> Stephen
> 
> On 09/13/2012 08:43 AM, Kirk Wythers wrote:
>> I am perplexed by some odd scripting behavior and am hoping that someone can point out the (probably stupid) mistake I am making.
>> 
>> I use a simple for loop with g.mlist an r.what to query some climate data. I have run this script before and never had any trouble with it. However, today I notice that it is returning fewer data points from my climate data than the number of coordinates that I am querying. For example I have a file "coords" that contains 8973 lines of coordinates. This should return 8973 lines of data from grass. However, the script is returning 8925 lines of data. I'm not getting any errors and can think of no reason the script should behave this way.
>> 
>> Any ideas?
>> 
>> 
>> 
>> Here is a copy of my shell script
>> 
>> #!/bin/bash
>> 
>> #test to see if script is being run from GRASS
>> 
>> if test "$GISBASE" = ""; then
>>        echo "You must be in GRASS to run this program"
>>        exit
>> fi
>> 
>> # Use input text file for coords in the format: lon lat (easting northing) single
>> # space between coords. Example: -98.42072 55.91481. Must use real coordinates, no blanks.
>> # Script will create file for each $MAP in the list. g.mlist can also take the "pattern"
>> # argument which takes regular expressions. For example: pattern="*" returns all
>> # maps in the database.
>> 
>> for MAP in `g.mlist type=rast pattern="HIST_bio_12"`; do
>>    r.what --verbose input="$MAP"<  ~/Desktop/worldclim/coords>  ~/Desktop/worldclim/"$MAP".txt;
>> 
>> echo "$MAP"
>> 
>> done
>> _______________________________________________
>> grass-user mailing list
>> grass-user at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/grass-user
> 
> -- 
> Stephen Sefick
> **************************************************
> Auburn University
> Biological Sciences
> 331 Funchess Hall
> Auburn, Alabama
> 36849
> **************************************************
> sas0025 at auburn.edu
> http://www.auburn.edu/~sas0025
> **************************************************
> 
> Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods.  We are mammals, and have not exhausted the annoying little problems of being mammals.
> 
>                                -K. Mullis
> 
> "A big computer, a complex algorithm and a long time does not equal science."
> 
>                              -Robert Gentleman
> 
> 



More information about the grass-user mailing list