Index: trunk/MagicSoft/Mars/datacenter/scripts/insertdatasets
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/insertdatasets	(revision 7938)
+++ trunk/MagicSoft/Mars/datacenter/scripts/insertdatasets	(revision 7944)
@@ -32,22 +32,15 @@
 #
 
+source `dirname $0`/sourcefile
+printprocesslog "INFO starting $0"
 program=insertdatasets
-source `dirname $0`/sourcefile
 
 set -C
 
-cd $mars
-
-datetime=`date +%F-%H-%M-%S`
-lockfile=$lockpath/lock-insertdatasets.txt
-
-scriptlogpath=$runlogpath/$program
-makedir $scriptlogpath
-
-scriptlog=$scriptlogpath/insertdatasets-$datetime.log
-
+scriptlog=$runlogpath/$program-$datetime.log
 date >> $scriptlog 2>&1
 
 # check if script is already running
+lockfile=$lockpath/lock-$program.txt
 checklock  >> $scriptlog 2>&1
 
@@ -57,5 +50,8 @@
 echo "" >> $scriptlog 2>&1 
 
+cd $mars
+
 # extract information from dataset file and insert it into db with the macro insertdataset.C
+printprocesslog "INFO inserting dataset information into db"
 for datasetfile in ${datasetfiles[@]}
 do 
@@ -74,4 +70,5 @@
       echo "number in filename and in file are not the same " >> $scriptlog 2>&1 
       echo " -> continue with next dataset" >> $scriptlog 2>&1 
+      printprocesslog "ERROR number in filename and file are not the same for dataset $no2"
       continue
    fi
@@ -98,16 +95,21 @@
    insertdatasetlog=$insertdatasetpath/insertdataset-$no3.log
 
+   printprocesslog "INFO inserting dataset $no2"
    # insert information into db
    check0=`root -q -b $macrospath/insertdataset.C+\("\"$no2\""\,"\"$source\""\,"\"$wobble\""\,"\"$comment\""\,kFALSE\) | tee $insertdatasetlog | grep int | sed -e 's/(int)//'`
    case $check0 in 
-      1)   echo "check0=$check0 -> everything ok " >> $scriptlog 2>&1 ;;
-      *)   echo "check0=$check0 -> ERROR " >> $scriptlog 2>&1 ;;
+      1)   echo " check0=$check0 -> everything ok " >> $scriptlog 2>&1 
+           printprocesslog "INFO dataset $no2 successfully inserted"
+           ;;
+      0)   echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1 
+           printprocesslog "WARN connection to DB failed"
+           check="no"
+           ;;
+      *)   echo " check0=$check0 -> ERROR " >> $scriptlog 2>&1 
+           printprocesslog "ERROR $program.C failed for dataset $no2"
+           ;;
    esac
 done
 
-rm -v $lockfile >> $scriptlog 2>&1 
+finish >> $scriptlog 2>&1
 
-set +C
-
-date  >> $scriptlog 2>&1
-
