Index: trunk/DataCheck/CheckRawData.sh
===================================================================
--- trunk/DataCheck/CheckRawData.sh	(revision 12971)
+++ trunk/DataCheck/CheckRawData.sh	(revision 12972)
@@ -1,3 +1,9 @@
 #!/bin/bash
+
+# this script has been written to run on La Palma on the machine data
+#   i.e. paths are only working on this machine
+# the script starts from the zipped files
+#   this causes a delay until files are in the database
+#   because they have to be rsynced and zipped first (see RsyncRawData.sh, ZipRawData.sh)
 
 # missing
@@ -10,5 +16,5 @@
 
 doupdate="yes" # update all entries
-#doupdate="no" # fill only entries which are not yet existing #default
+doupdate="no" # fill only entries which are not yet existing #default
 
 source `dirname $0`/Sourcefile.sh
@@ -31,4 +37,21 @@
 then 
    printprocesslog "ERROR "$factpath"/fitsdump is not available."
+   finish
+fi
+
+# check if paths are available
+if ! ls /daq/raw >/dev/null 2>&1
+then 
+   printprocesslog "ERROR /daq/raw is not available."
+   finish
+fi
+if ! ls /loc_data/raw >/dev/null 2>&1
+then 
+   printprocesslog "ERROR /loc_data/raw is not available."
+   finish
+fi
+if ! ls /loc_data/zipraw >/dev/null 2>&1
+then 
+   printprocesslog "ERROR /loc_data/zipraw is not available."
    finish
 fi
@@ -117,7 +140,8 @@
       
       # check if entry already exists
-      query3="SELECT fNight FROM RunInfo WHERE Concat(fNight, '_', LPAD(fRunID, 3, 0))='"$numberfromname"'"
-      printprocesslog "DEBUG check if entry already exists in DB. QUERY: "$query3
-      result3=`/usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -e "$query3"`
+      query="SELECT fNight FROM RunInfo WHERE Concat(fNight, '_', LPAD(fRunID, 3, 0))='"$numberfromname"'"
+      printprocesslog "DEBUG check if entry already exists in DB. QUERY: "$query
+      #result3=`/usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -e "$query3"`
+      result3=`sendquery`
 
       # only proceed with file 
@@ -264,7 +288,8 @@
       fi
       # get runtype
-      query2="SELECT fRunTypeKEY FROM RunType WHERE fRunTypeName='"$runtype"'"
-      printprocesslog "DEBUG get run type from DB. QUERY:"$query2
-      result2=( `/usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -e "$query2"` )
+      query="SELECT fRunTypeKEY FROM RunType WHERE fRunTypeName='"$runtype"'"
+      printprocesslog "DEBUG get run type from DB. QUERY:"$query
+      #result2=( `/usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -e "$query2"` )
+      result2=( `sendquery` )
       if [ ${#result2} -eq 0 ]
       then 
@@ -274,8 +299,9 @@
 
       # check if entry has already checksums
-      query5="SELECT fNight FROM RunInfo WHERE Concat(fNight, '_', LPAD(fRunID, 3, 0))='"$numberfromname"'"
-      query5=$query5" AND NOT ISNULL(fMd5sumRaw) AND NOT ISNULL(fMd5sumRawZip)"
-      printprocesslog "DEBUG check if md5sums are alreay in DB. QUERY:"$query5
-      result5=`/usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -e "$query5"`
+      query="SELECT fNight FROM RunInfo WHERE Concat(fNight, '_', LPAD(fRunID, 3, 0))='"$numberfromname"'"
+      query=$query" AND NOT ISNULL(fMd5sumRaw) AND NOT ISNULL(fMd5sumRawZip)"
+      printprocesslog "DEBUG check if md5sums are alreay in DB. QUERY:"$query
+      #result5=`/usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -e "$query5"`
+      result5=`sendquery`
 
       # get md5sums of raw and zip file
@@ -305,89 +331,91 @@
       if [ "$result3" == "" ]
       then 
-         query4="INSERT"
+         query="INSERT"
          querymid=" fNight="$runnumber", fRunID="$filenumberfromname", "
          querystop=
       else
-         query4="UPDATE"
+         query="UPDATE"
          querymid=
          querystop=" WHERE fNight="$runnumber" AND fRunID="$filenumberfromname
       fi
-      query4=$query4" RunInfo SET "$querymid" fRunTypeKey="${result2[1]}
+      query=$query" RunInfo SET "$querymid" fRunTypeKey="${result2[0]}
       if [ $numfitserrors -eq 0 ]
       then 
-         query4=$query4", fRunStart='"$runstart"', fRunStop='"$runstop"'"
+         query=$query", fRunStart='"$runstart"', fRunStop='"$runstop"'"
          if [ "$numevents" != "" ]
          then
-            query4=$query4", fNumEvents="$numevents
+            query=$query", fNumEvents="$numevents
          fi
          if [ "$roi" != "" ]
          then
-            query4=$query4", fROI="$roi
+            query=$query", fROI="$roi
          fi
          if [ "$roitm" != "" ]
          then
-            query4=$query4", fROITimeMarker="$roitm
+            query=$query", fROITimeMarker="$roitm
          fi
          if [ "$numphys" != "" ]
          then
-            query4=$query4", fNumPhysicsTrigger="$numphys
+            query=$query", fNumPhysicsTrigger="$numphys
          fi
          if [ "$numext1" != "" ]
          then
-            query4=$query4", fNumExt1Trigger="$numext1
+            query=$query", fNumExt1Trigger="$numext1
          fi
          if [ "$numext2" != "" ]
          then
-            query4=$query4", fNumExt2Trigger="$numext2
+            query=$query", fNumExt2Trigger="$numext2
          fi
          if [ "$numelp" != "" ]
          then
-            query4=$query4", fNumELPTrigger="$numelp
+            query=$query", fNumELPTrigger="$numelp
          fi
          if [ "$numilp" != "" ]
          then
-            query4=$query4", fNumILPTrigger="$numilp
+            query=$query", fNumILPTrigger="$numilp
          fi
          if [ "$numped" != "" ]
          then
-            query4=$query4", fNumPedestalTrigger="$numped
+            query=$query", fNumPedestalTrigger="$numped
          fi
          if [ "$numtime" != "" ]
          then
-            query4=$query4", fNumTimeTrigger="$numtime
+            query=$query", fNumTimeTrigger="$numtime
          fi
          if [ "$numoth" != "" ]
          then
-            query4=$query4", fNumOtherTrigger="$numoth
+            query=$query", fNumOtherTrigger="$numoth
          fi
       fi
       if [ "$md5sum" != "" ]
       then
-         query4=$query4", fMd5sumRaw='"$md5sum"', fMd5sumRawZip='"$md5sumzip"'"
+         query=$query", fMd5sumRaw='"$md5sum"', fMd5sumRawZip='"$md5sumzip"'"
       fi
       if [ "$numdrsfiles" != "" ]
       then
-         query4=$query4", fHasDrsFile="$numdrsfiles
+         query=$query", fHasDrsFile="$numdrsfiles
       fi
       if [ "$step" != "" ]
       then
-         query4=$query4", fDrsStep="$step
+         query=$query", fDrsStep="$step
       fi
       if [ "$compiletime" != "" ]
       then
-         query4=$query4", fCompileTime='"$compiletime"'"
+         query=$query", fCompileTime='"$compiletime"'"
       fi
       if [ "$revnum" != "" ]
       then
-         query4=$query4", fRevisionNumber='"$revnum"'"
-      fi
-      query4=$query4", fFitsFileErrors="$numfitserrors
-      query4=$query4" "$querystop
-      printprocesslog "INFO insert/update entry in DB. QUERY: "$query4
-      if ! /usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -e "$query4"
-      then
-         printprocesslog "ERROR insert/update of "$numfromfile" to mysql failed."
-         finish
-      fi
+         query=$query", fRevisionNumber='"$revnum"'"
+      fi
+      query=$query", fFitsFileErrors="$numfitserrors
+      query=$query" "$querystop
+      printprocesslog "INFO insert/update entry in DB. QUERY: "$query
+      # send query to DB
+      sendquery >/dev/null
+      #if ! /usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -e "$query4"
+      #then
+      #   printprocesslog "ERROR insert/update of "$numfromfile" to mysql failed."
+      #   finish
+      #fi
    done
 done
