Index: trunk/MagicSoft/Mars/datacenter/scripts/fillcamera
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/fillcamera	(revision 9217)
+++ trunk/MagicSoft/Mars/datacenter/scripts/fillcamera	(revision 9355)
@@ -1,3 +1,3 @@
-#!/bin/sh
+	#!/bin/sh
 #
 # ========================================================================
@@ -35,10 +35,7 @@
 set -C
 
-scriptlog=$runlogpath/$program-$datetime.log
-date >> $scriptlog 2>&1
-
 # check if script is already running
 lockfile=$lockpath/lock-$program.txt
-checklock  >> $scriptlog 2>&1
+checklock 
 
 getdbsetup
@@ -48,6 +45,5 @@
 #workaround
 cameradirs=`find /magic/montecarlo/camera -maxdepth 4 -mindepth 2 -type d ! -name Gamma ! -name Muon ! -name Proton ! -name Spot_?.?`
-echo "camera dirs: "${cameradirs[@]}  >> $scriptlog 2>&1
-echo "" >> $scriptlog 2>&1
+printprocesslog "INFO camera dirs: "${cameradirs[@]} 
 
 cd $mars
@@ -66,7 +62,7 @@
    fi
    epo=`echo $cameradir | cut -d/ -f5` #epoch
-   echo "dir: "$cameradir >> $scriptlog 2>&1
+   printprocesslog "INFO dir: "$cameradir 
    fillcamerapath=$logpath/$program
-   makedir $fillcamerapath >> $scriptlog 2>&1
+   makedir $fillcamerapath 
    fillcameralog=$fillcamerapath/$program-$epo-$par-$spot-$cam.log
    
@@ -74,22 +70,18 @@
 #   check0=`root -q -b $macrospath/fillcamera.C+\("\"$cameradir\""\,kTRUE\) | tee $fillcameralog | intgrep`
    case $check0 in 
-      1)   echo "check0=$check0 -> everything ok " >> $scriptlog 2>&1 
-           printprocesslog "INFO fillcamera run successfully for dir $cameradir"
+      1)   printprocesslog "INFO fillcamera run successfully for dir $cameradir (check0=$check0)"
            ;;
-      0)   echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1 
-           printprocesslog "WARN connection to DB failed"
+      0)   printprocesslog "WARN connection to DB failed (check0=$check0)"
            check="no"
            ;;
-      *)   echo "check0=$check0 -> ERROR " >> $scriptlog 2>&1 
-           printprocesslog "ERROR $program.C failed for dir $cameradir"
+      *)   printprocesslog "ERROR $program.C failed for dir $cameradir (check0=$check0)"
            ;;
    esac
    
    printprocesslog "INFO linking cal and ped files"
-   echo "linking cal and ped files" >> $scriptlog 2>&1
    
    if [ $cam = "Cal_and_Ped" ];
    then
-      echo "Cal_and_Ped folder, no cal and ped files will be linked" >> $scriptlog 2>&1
+      printprocesslog "INFO Cal_and_Ped folder, no cal and ped files will be linked" 
    else
 
@@ -99,6 +91,6 @@
       calfile=`find $mccampath/$epo/Cal_and_Ped -name *_C_*.root`
    
-      echo "calfile for epoch $epo : " $calfile >> $scriptlog 2>&1
-      echo "pedfile for epoch $epo : " $pedfile >> $scriptlog 2>&1
+      printprocesslog "INFO calfile for epoch $epo : " $calfile 
+      printprocesslog "INFO pedfile for epoch $epo : " $pedfile 
    
       #check number of files
@@ -107,9 +99,6 @@
       if [ "$numfiles" != "2" ]
       then
-      	echo "too many or too less files in the directory $epo/Cal_and_Ped -> exit" >> $scriptlog 2>&1
-        rm -v $lockfile >> $scriptlog 2>&1
-   	exit
-      	printprocesslog "ERROR too many ped and cal files found in $epo/Cal_and_Ped"
-      	finish >> $scriptlog 2>&1
+      	printprocesslog "ERROR too many or too less ped and cal files found in $epo/Cal_and_Ped"
+      	finish 
       fi
       
@@ -122,6 +111,6 @@
       cnum=`printf %08d $crun`
       pnum=`printf %08d $prun`
-      echo "calrun number: " $cnum >> $scriptlog 2>&1
-      echo "pedrun number: " $pnum >> $scriptlog 2>&1
+      printprocesslog "INFO calrun number: " $cnum 
+      printprocesslog "INFO pedrun number: " $pnum 
       #get all directories in the linked structure for the epoch
       #dirs=`find $mcrawpath/ -mindepth 3 -maxdepth 3 -type d`
@@ -142,10 +131,10 @@
          if ls $dir | grep MonteCarlo | grep $pnum
          then 
-            echo "P run already there, do mysql update" >> $scriptlog 2>&1
+            printprocesslog "INFO P run already there, do mysql update" 
    #         continue
             mysql -ss -u $us --password=$pw --host=$ho $db -e " $pupdate "
          else 
-            echo "linking P run for epoch $epo" >> $scriptlog 2>&1
-            ln -sv $pedfile $newpedfile >> $scriptlog 2>&1
+            printprocesslog "INFO linking P run for epoch $epo" 
+            ln -sv $pedfile $newpedfile 
             mysql -ss -u $us --password=$pw --host=$ho $db -e " $pupdate "
          fi
@@ -153,10 +142,10 @@
          if ls $dir | grep MonteCarlo | grep $cnum
          then 
-            echo "C run already there, do mysql update" >> $scriptlog 2>&1
+            printprocesslog "INFO C run already there, do mysql update" 
    #         continue
             mysql -ss -u $us --password=$pw --host=$ho $db -e " $cupdate "
          else 
-            echo "linking C run for epoch $epo" >> $scriptlog 2>&1
-            ln -sv $calfile $newcalfile >> $scriptlog 2>&1
+            printprocesslog "INFO linking C run for epoch $epo" 
+            ln -sv $calfile $newcalfile 
             mysql -ss -u $us --password=$pw --host=$ho $db -e " $cupdate "
          fi
@@ -211,4 +200,4 @@
 
 
-finish >> $scriptlog 2>&1
-
+finish 
+
