Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 7805)
+++ trunk/MagicSoft/Mars/Changelog	(revision 7806)
@@ -18,4 +18,16 @@
 
                                                  -*-*- END OF LINE -*-*-
+ 2006/07/26 Daniela Dorner
+
+   * datacenter/scripts/movingrawfiles:
+     - changed machine
+     - added logging
+     - added launching of filesondisk, when files have been moved
+
+   * datacenter/scripts/filesondisk:
+     - added logging
+
+
+
  2006/07/26 Thomas Bretz
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/filesondisk
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/filesondisk	(revision 7805)
+++ trunk/MagicSoft/Mars/datacenter/scripts/filesondisk	(revision 7806)
@@ -48,45 +48,61 @@
 source /home/$user/Mars/datacenter/scripts/sourcefile
 
+set -C
+
 cd $mars
+
+program=filesondisk
+
+lockfile=$lockpath/lock-$program.txt
+
+scriptlogpath=$logpath/run/$program/`date +%Y`
+makedir $scriptlogpath
+scriptlog=$scriptlogpath/$program-$datetime.log
+
+date >> $scriptlog 2>&1
+
+# check if script is already running
+checklock  >> $scriptlog 2>&1
+
 date=`date +%F`
 
 subsystemdir=/magic/subsystemdata
-filesondisklogpath=$logpath/filesondisk/`date +%Y`
+filesondisklogpath=$logpath/$program/`date +%Y/%m`
 makedir $filesondisklogpath 
 
 
-echo "checking disk for ccfiles..." 
-filename=$filesondisklogpath/ccfilesondisk-$date.txt
+echo "checking disk for ccfiles..."  >> $scriptlog 2>&1
+filename=$filesondisklogpath/ccfilesondisk-$datetime.txt
 column=fCCFileAvail
 find $subsystemdir/cc/ -name '*_S.rep' | cut -d_ -f2  > $filename
 
-echo "resetting runs..."
-check3=`root -q -b $macrospath/resetallruns.C+\("\"$filename\""\,"\"$column\""\) | tee $filesondisklogpath/resetall-$column-$date.log | grep int | sed -e 's/(int)//'`
+echo "resetting runs..." >> $scriptlog 2>&1
+check3=`root -q -b $macrospath/resetallruns.C+\("\"$filename\""\,"\"$column\""\) | tee $filesondisklogpath/resetall-$column-$datetime.log | grep int | sed -e 's/(int)//'`
 
 case $check3 in 
-   1)   echo "check3=$check3 -> everything ok -> reset is done";;
-   *)   echo "check3=$check3 -> ERROR -> something went wrong while resetting";;
+   1)   echo "check3=$check3 -> everything ok -> reset is done" >> $scriptlog 2>&1 ;;
+   *)   echo "check3=$check3 -> ERROR -> something went wrong while resetting" >> $scriptlog 2>&1 ;;
 esac
 
 
-echo "checking disk for cacofiles..." 
-filename=$filesondisklogpath/cacofilesondisk-$date.txt
+echo "checking disk for cacofiles..."  >> $scriptlog 2>&1 
+filename=$filesondisklogpath/cacofilesondisk-$datetime.txt
 column=fCaCoFileAvail
 find $subsystemdir/caco/ -name '*.txt' | cut -d_ -f8 | grep [0-9] > $filename
 
-echo "resetting runs..."
-check0=`root -q -b $macrospath/resetallruns.C+\("\"$filename\""\,"\"$column\""\) | tee $filesondisklogpath/resetall-$column-$date.log | grep int | sed -e 's/(int)//'`
+echo "resetting runs..." >> $scriptlog 2>&1 
+check0=`root -q -b $macrospath/resetallruns.C+\("\"$filename\""\,"\"$column\""\) | tee $filesondisklogpath/resetall-$column-$datetime.log | grep int | sed -e 's/(int)//'`
 
 case $check0 in 
-   1)   echo "check0=$check0 -> everything ok -> reset is done";;
-   *)   echo "check0=$check0 -> ERROR -> something went wrong while resetting";;
+   1)   echo "check0=$check0 -> everything ok -> reset is done" >> $scriptlog 2>&1 ;;
+   *)   echo "check0=$check0 -> ERROR -> something went wrong while resetting" >> $scriptlog 2>&1 ;;
 esac
 
-echo "checking missing cacofiles..."
-check1=`root -q -b $macrospath/findcacofiles.C+\("\"$date\""\,"\"$filesondisklogpath\""\) | tee $filesondisklogpath/findcacofiles-$date.log | grep int | sed -e 's/(int)//'`
+echo "checking missing cacofiles..." >> $scriptlog 2>&1 
+check1=`root -q -b $macrospath/findcacofiles.C+\("\"$date\""\,"\"$filesondisklogpath\""\) | tee $filesondisklogpath/findcacofiles-$datetime.log | grep int | sed -e 's/(int)//'`
 
 case $check1 in 
-   1)   echo "check1=$check1 -> everything ok -> missing cacofiles are found";;
-   *)   echo "check1=$check1 -> ERROR -> something went wrong while resetting";;
+   1)   echo "check1=$check1 -> everything ok -> missing cacofiles are found" >> $scriptlog 2>&1 ;;
+   *)   echo "check1=$check1 -> ERROR -> something went wrong while resetting" >> $scriptlog 2>&1 ;;
 esac
 
@@ -95,11 +111,11 @@
 do 
    runno=$missingcacorun
-   echo "no cacofile found for run "$runno
-   echo "finding cacofile"
+   echo "no cacofile found for run "$runno >> $scriptlog 2>&1 
+   echo "finding cacofile" >> $scriptlog 2>&1 
    ccfile=`find $subsystemdir/cc/ -name [2][0][0-2][0-9][0,1][0-9][0-3][0-9]_*${runno}_[P,D,C,S]_*_S.rep`   
-   echo "ccfile: "$ccfile
+   echo "ccfile: "$ccfile  >> $scriptlog 2>&1 
    if [ "$ccfile" = "" ]
    then
-      echo "no ccfile found for run "$runno
+      echo "no ccfile found for run "$runno >> $scriptlog 2>&1 
       continue
    fi
@@ -114,31 +130,33 @@
          continue
       else
-         echo "inserting cacofile $file for run $missingcacorun..."
+         echo "inserting cacofile $file for run $missingcacorun..." >> $scriptlog 2>&1 
          check2=`root -q -b $macrospath/insertcacofile.C+\("\"$runno\""\,"\"$newrun\""\) | tee $filesondisklogpath/insertcacofile-$missingcacorun.log | grep int | sed -e 's/(int)//'`
 
          case $check2 in
-            1)   echo "check2=$check2 -> everything ok -> insert is done";;
-            *)   echo "check2=$check2 -> ERROR -> something went wrong while inserting run "$missingcacorun;;
+            1)   echo "check2=$check2 -> everything ok -> insert is done" >> $scriptlog 2>&1 ;;
+            *)   echo "check2=$check2 -> ERROR -> something went wrong while inserting run "$missingcacorun >> $scriptlog 2>&1 ;;
          esac
          break
       fi
    done
-   echo "cacofile: "$cacofile
+   echo "cacofile: "$cacofile >> $scriptlog 2>&1 
 
 done
 
 
-echo "checking disk for rawfiles..." 
-filename=$filesondisklogpath/rawfilesondisk-$date.txt
+echo "checking disk for rawfiles..."  >> $scriptlog 2>&1 
+filename=$filesondisklogpath/rawfilesondisk-$datetime.txt
 column=fRawFileAvail
 find $datapath -name '*.raw' -o -name '*.gz' | cut -d_ -f2 > $filename
 
-echo "resetting runs..."                                    
-check4=`root -q -b $macrospath/resetallruns.C+\("\"$filename\""\,"\"$column\""\) | tee $filesondisklogpath/resetall-$column-$date.log | grep int | sed -e 's/(int)//'` 
+echo "resetting runs..." >> $scriptlog 2>&1 
+check4=`root -q -b $macrospath/resetallruns.C+\("\"$filename\""\,"\"$column\""\) | tee $filesondisklogpath/resetall-$column-$datetime.log | grep int | sed -e 's/(int)//'` 
 
 case $check4 in 
-   1)   echo "check4=$check4 -> everything ok -> reset is done";;
-   *)   echo "check4=$check4 -> ERROR -> something went wrong while resetting";;
+   1)   echo "check4=$check4 -> everything ok -> reset is done" >> $scriptlog 2>&1 ;;
+   *)   echo "check4=$check4 -> ERROR -> something went wrong while resetting" >> $scriptlog 2>&1 ;;
 esac
 
+finish >> $scriptlog 2>&1
 
+
Index: trunk/MagicSoft/Mars/datacenter/scripts/movingrawfiles
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/movingrawfiles	(revision 7805)
+++ trunk/MagicSoft/Mars/datacenter/scripts/movingrawfiles	(revision 7806)
@@ -30,20 +30,49 @@
 # 
 
+user=`whoami`
+source /home/$user/Mars/datacenter/scripts/sourcefile
+
+set -C
+
+program=movingrawfiles
+
+lockfile=$lockpath/lock-$program.txt
+
+scriptlogpath=$logpath/run/$program/`date +%Y`
+makedir $scriptlogpath
+scriptlog=$scriptlogpath/$program-$datetime.log
+
+date >> $scriptlog 2>&1
+
+# check if script is already running
+checklock  >> $scriptlog 2>&1
+
+
 umask 0002
 
 # change permission for files 
-ssh tape@dc07 chmod -R g+w /magic/datacenter/fromtape/rawdata/*
+ssh tape@dc07 chmod -R g+w /magic/datacenter/fromtape/rawdata/* >> $scriptlog 2>&1
 # output for chmod with -v or -c (only changes)
 
 #find directories, which have to be copied
 dirs=`ls /magic/datacenter/fromlapalma/RAWchk/*/*.finished | sed -e 's/RAWchk/RAW/g' | cut -d/ -f1-6`
-# change permission for this dirctories
-ssh lapalma@apollo chmod -R g+w $dirs
-# move directories to the tapedirectory
-mv -v $dirs /magic/datacenter/fromtape/rawdata/
+if [ ! "$dirs" == "" ]
+then
+   # change permission for this dirctories
+   ssh lapalma@apollo chmod -R g+w $dirs >> $scriptlog 2>&1
+   # move directories to the tapedirectory
+   mv -v $dirs /magic/datacenter/fromtape/rawdata/ >> $scriptlog 2>&1 
+fi
 
 
 # find rawfiles
 rawfiles=`find /magic/datacenter/fromtape/rawdata/ -name '*.*'`
+
+if [ "$rawfiles" == "" ]
+then
+   echo "no files to move -> exit" >> $scriptlog 2>&1 
+   finish >> $scriptlog 2>&1 
+fi
+
 for rawfile in $rawfiles
 do 
@@ -52,22 +81,14 @@
    newrawfile=`echo $rawfile | sed -e 's/center\/fromtape\/rawdata/\/rawfiles/g' -e 's/_/\//1' -e 's/_/\//1'`
    newdir=`dirname $newrawfile`
-   if [ ! -d $newdir ]
-   then
-     mkdir -pv $newdir 
-     if [ ! -d $newdir ]
-     then 
-        echo "could not make dir "$newdir
-        exit
-     fi
-   fi
+   makedir $newdir >> $scriptlog 2>&1 
 
-   mv -v $rawfile $newrawfile
-#   if gzip -1c $rawfile > $newrawfile.gz
-#   then 
-#      rm -v $newrawfile
-#      rm -v $rawfile
-#   fi
+   mv -v $rawfile $newrawfile >> $scriptlog 2>&1 
 done
 
-rmdir -v /magic/datacenter/fromtape/rawdata/*
+rmdir -v /magic/datacenter/fromtape/rawdata/* >> $scriptlog 2>&1 
 
+echo "launching filesondisk" >> $scriptlog 2>&1 
+$scriptspath/filesondisk&
+
+finish >> $scriptlog 2>&1
+
