Index: /trunk/MagicSoft/Mars/datacenter/scripts/sourcefile
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/scripts/sourcefile	(revision 9455)
+++ /trunk/MagicSoft/Mars/datacenter/scripts/sourcefile	(revision 9456)
@@ -56,4 +56,8 @@
       then 
          echo "could not make dir "$@
+         if ! [ "$processlog" = "" ]
+         then
+            echo `date +%F\ %T`" "`whoami`"@"$HOSTNAME" "`basename $0`"["$$"] could not make dir "$@ >> $processlog
+         fi
          if ls $lockfile >/dev/null 2>&1
          then 
@@ -133,4 +137,18 @@
 Fmcstar=31
 Ffillmcstar=32
+Fcorsikasimtel=33
+Fchimp=34
+Fchimpcp=35
+Fctastar=36
+Fctastarcp=37
+FctastereoA=38
+FctastereoB=39
+FctastereoC=40
+FctastereoD=41
+FctastereoE=42
+FctastereoF=43
+FctastereoG=44
+FctastereoH=45
+Fctastereocp=46
 
 # setup for jobmanager:
@@ -165,4 +183,5 @@
 alias 'intgrep'='grep -E -o \\\(int\\\)[0-9]+$ | grep -E -o [0-9]+'
 
+
 # in the following the functions, which are needed by several scripts, are 
 # defined
@@ -177,16 +196,15 @@
 
 # function to check if a process is already locked
+#  command line option can be used to execute something, e.g. 'continue'
 function checklock()
 {
-   date > $lockfile 
-   checklock0=$?
-   case $checklock0 in
-      0)   printprocesslog "INFO checklock0=$checklock0 -> continue " 
-           ;;
-      1)   printprocesslog "WARN checklock0=$checklock0 -> file $lockfile exists"
-           $@
-           exit;;
-      *)   printprocesslog "ERROR checklock0=$checklock0 -> something went completely wrong" ;;
-   esac
+   if ! echo `date +%F\ %T`" "`whoami`"@"$HOSTNAME" "`basename $0`"["$$"] "`uname -a` > $lockfile 2>/dev/null
+   then 
+      printprocesslog "WARN lockfile $lockfile exists"
+      $@
+      exit
+   else
+      printprocesslog "INFO created lockfile $lockfile"
+   fi
 }
 
@@ -280,25 +298,30 @@
    getstepinfo
    # get query
-   query=" select "${prims[0]}
+   query=" SELECT "${prims[0]}
    for (( i=1 ; i < ${#prims[@]} ; i++ ))
    do
       query=$query", ${prims[$i]}"
    done
-   query=$query" from $table where "
+   query=$query" FROM $table WHERE "
    if ! echo $needs | grep '#' > /dev/null
    then
       for need in $needs
       do
-         query=$query" not isnull($need) and"
+         query=$query" NOT ISNULL($need) AND"
       done
    fi
-   query=$query" isnull($column) "
-   query=$query" and isnull(fStartTime) and isnull(fFailedTime) and isnull(fProgramId) and isnull(fReturnCode) "
-   query=$query" order by fPriority desc "
-   if [ "$@ " != " " ]
+   query=$query" ISNULL($column) "
+   if [ "$2 " != " " ]
    then 
-      query=$query" limit 0, $@ "
-   fi
-   printprocesslog "INFO QUERY: "$query
+      query=$query" AND fProductionHostKEY=$2 "
+   fi
+   query=$query" AND ISNULL(fStartTime) AND ISNULL(fFailedTime) AND ISNULL(fProgramId) AND ISNULL(fReturnCode) "
+   query=$query" ORDER BY fPriority desc "
+   if [ "$1 " != " " ]
+   then 
+      query=$query" limit 0, $1 "
+   fi
+#   echo " QUERY: "$query
+   printprocesslog "INFO gettodo QUERY: "$query
    if ! process=`mysql -s -u $us --password=$pw --host=$ho $db -e " $query "`
    then
@@ -325,16 +348,21 @@
    getstepinfo
    # get query
-   query=" select count(*) from $table where "
+   query=" SELECT COUNT(*) FROM $table WHERE "
    if ! echo $needs | grep '#' > /dev/null
    then
       for need in $needs
       do
-         query=$query" not isnull($need) and"
+         query=$query" NOT ISNULL($need) AND"
       done
    fi
-   query=$query" isnull($column) "
-   query=$query" and isnull(fStartTime) and isnull(fFailedTime) and isnull(fProgramId) and isnull(fReturnCode) "
-   query=$query" group by $column "
-#   printprocesslog "INFO  QUERY: "$query
+   query=$query" ISNULL($column) "
+   if [ "$1 " != " " ]
+   then 
+      query=$query" AND fProductionHostKEY=$1 "
+   fi
+   query=$query" AND ISNULL(fStartTime) AND ISNULL(fFailedTime) AND ISNULL(fProgramId) AND ISNULL(fReturnCode) "
+   query=$query" GROUP BY $column "
+#   echo "QUERY: "$query
+   printprocesslog "INFO getstatus QUERY: "$query
    if ! numproc=`mysql -s -u $us --password=$pw --host=$ho $db -e " $query "`
    then
@@ -383,7 +411,8 @@
    for (( i=1 ; i < ${#prims[@]} ; i++ ))
    do
-      query=$query" and ${prims[$i]}='${primaries[$s*${#prims[@]}+$i]}' "
+      query=$query" AND ${prims[$i]}='${primaries[$s*${#prims[@]}+$i]}' "
    done   
-   printprocesslog "INFO QUERY: "$query
+#   echo " QUERY: "$query
+   printprocesslog "INFO setstatus QUERY: "$query
    if ! mysql -s -u $us --password=$pw --host=$ho $db -e " $query "
    then
@@ -398,4 +427,5 @@
 {
    getdbsetup
+   printprocesslog "INFO sendquery QUERY: "$query
    if ! val=`mysql -s -u $us --password=$pw --host=$ho $db -e " $query "`
    then
