#!/bin/sh
#
# ========================================================================
#
# *
# * This file is part of MARS, the MAGIC Analysis and Reconstruction
# * Software. It is distributed to you in the hope that it can be a useful
# * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
# * It is distributed WITHOUT ANY WARRANTY.
# *
# * Permission to use, copy, modify and distribute this software and its
# * documentation for any purpose is hereby granted without fee,
# * provided that the above copyright notice appear in all copies and
# * that both that copyright notice and this permission notice appear
# * in supporting documentation. It is provided "as is" without express
# * or implied warranty.
# *
#
#
#   Author(s): Daniela Dorner  05/2005 <mailto:dorner@astro.uni-wuerzburg.de>
#
#   Copyright: MAGIC Software Development, 2000-2006
#
#
# ========================================================================
#

date=`date +.%Y.%m.%d.%H.%M.%S`
olddb=MyMagic
newdb=TestSequ2
pw=d99swMT!
host=vela

query="select fRunNumber from RunData where fRunNumber > 32000";
runs=`mysql -s -u MAGIC --password=$pw --host=$host MyMagic -e " $query "`

for run in $runs
do 
   query="select fSequenceFirst from RunData where fRunNumber=$run"
   s1=`mysql -s -u MAGIC --password=$pw --host=$host $olddb -e " $query "`
   s2=`mysql -s -u test  --password=Ics+eaTD --host=$host $newdb -e " $query "`
   if [ $s1 -eq 0 ] && [ $s2 -eq 0 ]
   then 
      continue
   fi
   if [ $s1 -eq $s2 ]
   then 
      continue
   fi
   echo "run: $run sequ#: $s1 -> $s2"
   echo "run: $run sequ#: $s1 -> $s2" >> sequ.changes$date
   if [ $s2 -eq 0 ]
   then 
      echo "run: $run sequ#: $s1 -> $s2" >> not-sequenced.anymore$date
   fi
done

