Index: trunk/MagicSoft/Mars/datacenter/scripts/dodatacheck
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/dodatacheck	(revision 7954)
+++ trunk/MagicSoft/Mars/datacenter/scripts/dodatacheck	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -36,5 +36,5 @@
 #    taken into account when doexclusions is running the next time
 # If this was successful, the status is inserted into the database using 
-# the macro setstatus.C
+# the function setstatus.
 #
 
@@ -63,12 +63,12 @@
 no=`printf %08d $run | cut -c 0-2`
 no2=`printf %08d $run`
-var1=$date
-var2=$no2
-rawfile=`find /magic/data/rawfiles/ -name *${run}_[D,P,C,S]_*_E.raw -o -name *${run}_[D,P,C,S]_*_E.raw.gz`
+query="SELECT DATE_FORMAT(ADDDATE(fRunStart, INTERVAL +13 HOUR), '%Y/%m/%d') FROM RunData where fRunNumber="$run
+date=`sendquery`
+rawfile=`find /magic/data/rawfiles/$date -name *${run}_[D,P,C,S]_*_E.raw -o -name *${run}_[DPCS]_*_E.raw.gz`
 echo "rawfile: "$rawfile >> $scriptlog 2>&1
-date=`echo $rawfile | cut -c 22-31`
 # for sinope the date is needed in the format YYYY-MM-DD
 date2=`echo $date | sed -e 's/\//-/g'`
 
+primvar=$no2
 setstatus "start" >> $scriptlog 2>&1
 
@@ -113,13 +113,13 @@
    
    case $check2 in 
-       0)   echo " check2=$check2 -> everything ok -> go on with $program..." >> $scriptlog 2>&1
-            ;;
-       *)   echo " check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
-            printprocesslog "ERROR sinope $sin failed for $rawfile"
-            com=$Fsinope
-#            comadd=
-            check=$check2
-            setstatus "stop" >> $scriptlog 2>&1
-            continue 2;;
+      0)   echo " check2=$check2 -> everything ok -> go on with $program..." >> $scriptlog 2>&1
+           ;;
+      *)   echo " check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
+           printprocesslog "ERROR sinope $sin failed for $rawfile"
+           com=$Fsinope
+#           comadd=
+           check=$check2
+           setstatus "stop" >> $scriptlog 2>&1
+           continue 2;;
    esac
    check2=1
@@ -182,6 +182,4 @@
 starttime="NULL"
 failedtime="NULL"
-var1=$date
-var2=$no2
 setstatus "stop" >> $scriptlog 2>&1
 
