Opened 12 years ago

Closed 12 years ago

#295 closed defect (fixed)

WMS init and fill pyramid scripts fail when collection name is not the first one returned by RASQL select query

Reported by: Dirk Daems Owned by: Piero Campalani
Priority: minor Milestone: 8.4
Component: rasgeo Version: 8.3
Keywords: Cc:
Complexity: Medium

Description (last modified by Dirk Daems)

The WMS init script (init_wms.sh) and fill pyramid script (fill_pyramid.sh) contain a check to validate if the collection name exists in the RASBASE database.
The query

select r from RAS_COLLECTIONNAMES as r" --out string

returns the existing collection names but the output of the result objects is (according to AWK) not printed on separate lines which makes the check

while read coll; do 
  if [ "$coll" = "$COLLNAME" ]; then collExists=1; fi
  done <<< "$( rasql -q "select r from RAS_COLLECTIONNAMES as r" --out string | grep "Result object" | awk 'BEGIN { FS=" "}; { print $4 };' )"

to fail if the collection name passed to the script is not the first collection name returned by the RASQL select query.

Change History (11)

comment:1 by Dimitar Misev, 12 years ago

Milestone: 8.4
Owner: changed from Dimitar Misev to Piero Campalani
Status: newassigned

comment:2 by Dirk Daems, 12 years ago

Description: modified (diff)
Summary: WMS init script fails when collection name is not the first one returned by RASQL select queryWMS init and fill pyramid scripts fail when collection name is not the first one returned by RASQL select query

The same check fails for the WMS fill_pyramid script.

comment:3 by Piero Campalani, 12 years ago

Dirk,
here things work fine:

$ cat testAwk.sh 
while read coll; do 
        echo LINE: "$coll"  
done <<< "$( rasql -q "select r from RAS_COLLECTIONNAMES as r" --out string | grep "Result object" | awk 'BEGIN { FS=" "}; { print $4 };' )"

$ ./testAwk.sh
LINE: eobstest
LINE: MODIS_2008129_34S
LINE: mean_summer_airtemp_pyr_2
LINE: MODIS_AUSTRIA_2010170
LINE: mean_summer_airtemp_pyr_3
LINE: mean_summer_airtemp_pyr_1
LINE: mean_summer_airtemp
LINE: MODIS_33N_2010170_WGS84
LINE: mean_summer_airtemp_pyr
LINE: MODIS_2008129_34S_WGS84
LINE: greece_dem
LINE: mr
LINE: NIR_pyr
LINE: rgb
LINE: NIR
LINE: NIR_pyr_1
LINE: MODIS_35U

Which Unix shell are you using?

$ bash -version
GNU bash, version 4.2.24(1)-release (i686-pc-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

comment:4 by Dirk Daems, 12 years ago

Strange, my bash version is identical:

rasdaman@dirkdpc:~$ bash -version
GNU bash, version 4.2.24(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Result of your AWK script:

LINE: NDVI_pyr_5

while

rasql -q "select r from RAS_COLLECTIONNAMES as r" --out string

gives:

rasql: rasdaman query tool v1.0, rasdaman v8 -- generated on 19.11.2012 09:47:32.
opening database RASBASE at localhost:7001...ok
Executing retrieval query...ok
Query result collection has 22 element(s):
  Result object 1: user_selection
  Result object 2: NDVI_pyr_7
  Result object 3: NDVI_pyr_1
  Result object 4: mean_summer_airtemp_pyr_7
  Result object 5: mean_summer_airtemp
  Result object 6: mean_summer_airtemp_pyr_5
  Result object 7: NDVI_pyr_6
  Result object 8: mean_summer_airtemp_pyr_6
  Result object 9: NDVI_pyr_5
  Result object 10: mean_summer_airtemp_pyr_1
  Result object 11: NDVI_pyr_4
  Result object 12: mean_summer_airtemp_pyr_4
  Result object 13: mr2
  Result object 14: NDVI_pyr_3
  Result object 15: NDVI
  Result object 16: rgb
  Result object 17: mean_summer_airtemp_pyr_3
  Result object 18: NDVI_pyr
  Result object 19: NDVI_pyr_2
  Result object 20: mean_summer_airtemp_pyr
  Result object 21: mean_summer_airtemp_pyr_2
  Result object 22: mr
rasql done.

comment:5 by Piero Campalani, 12 years ago

Ok, let's go step by step.

What's your output there for this command?

rasql -q "select r from RAS_COLLECTIONNAMES as r" --out string | grep "Result object" | awk 'BEGIN { FS=" "}; { print $4 };'

comment:6 by Dimitar Misev, 12 years ago

Dirk,

most likely your awk is linked to mawk or a similar, I tried explicitly with mawk and also get one line back. Can you please install gawk (and remove mawk) and make sure it's the default on your system

$ ll /etc/alternatives/awk
lrwxrwxrwx 1 root root 13 Oct 27 20:01 /etc/alternatives/awk -> /usr/bin/gawk

comment:7 by Piero Campalani, 12 years ago

Yes, it's true.

Meanwhile I can patch the scripts by explicitly (requiring and) calling gawk instead of awk. I can either use grep or sed otherwise.
Comments?

comment:8 by Piero Campalani, 12 years ago

Ok, really too many awks in the scripts to be replaced, I just added it as requirement as with other binaries like wget or dc.
Patch: "More robust WMS utilities (tickets #295 #296)."

Dirk, please take care of checking the status here whe it is submitted.
Thanks.

in reply to:  8 comment:9 by Dimitar Misev, 12 years ago

Replying to pcampalani:

Ok, really too many awks in the scripts to be replaced, I just added it as requirement as with other binaries like wget or dc.
Patch: "More robust WMS utilities (tickets #295 #296)."

Yes I think that's best, gawk is anyway in the list of wiki:RequiredPackages

comment:10 by Dirk Daems, 12 years ago

Indeed, I was using mawk instead of gawk.

comment:11 by Piero Campalani, 12 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.