Index: trunk/MagicSoft/Mars/datacenter/scripts/zipscript
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/zipscript	(revision 9049)
+++ trunk/MagicSoft/Mars/datacenter/scripts/zipscript	(revision 9091)
@@ -32,5 +32,5 @@
 # to give the possibility to run several zipscripts at the same time, 
 # $1 is added
-program=zipscript$1
+program=zipscript2
 
 set -C
@@ -57,19 +57,31 @@
    echo "processing file $file..." >> $scriptlog 2>&1 
    runno=`basename $file | sed -e 's/.*20[01][0-9]\{5\}_\(M[12]_\)\?.*\([0-9]\{8\}\).\([0-9]\{3\}\)\?.*/\2/'`
-   query="SELECT fSequenceFirst FROM RunData WHERE fRunNumber="$runno
+   fileno=`basename $file | sed -e 's/.*20[01][0-9]\{5\}_\(M[12]_\)\?.*\([0-9]\{8\}\).\([0-9]\{3\}\)\?.*/\3/'`
+   telno=`basename $file | sed -e 's/.*20[01][0-9]\{5\}_\(M[12]_\)\?.*\([0-9]\{8\}\).\([0-9]\{3\}\)\?.*/\1/' | cut -c2`
+   # old runs have a fileno of 0
+   if [ "$fileno" == "" ]
+   then
+      fileno=0
+   fi
+   # old runs have a telno of 1
+   if [ "$telno" == "" ]
+   then
+      telno=1
+   fi
+   query="SELECT fSequenceFirst FROM RunData WHERE fRunNumber="$runno" AND fFileNumber="$fileno" AND fTelescopeNumber="$telno
    echo " sending query: $query" >> $scriptlog 2>&1 
    if ! seq=`sendquery`
    then
-      echo "querying seq for run $runno from the db did not work -> continue" >> $scriptlog 2>&1
-      printprocesslog "WARN query $seq for run $runno from the db did not work"
+      echo "querying seq for run M_${telno}${runno}.${fileno} from the db did not work -> continue" >> $scriptlog 2>&1
+      printprocesslog "WARN query $seq for run M_${telno}${runno}.${fileno} from the db did not work"
       continue
    fi
    if [ "$seq" == "" ] 
    then
-      echo "no seq found for run $runno -> locking only run..." >> $scriptlog 2>&1
+      echo "no seq found for run M_${telno}${runno}.${fileno} -> locking only run..." >> $scriptlog 2>&1
       seq=$runno
    fi
    echo "locking sequence $seq..."  >> $scriptlog 2>&1 
-   lockfile=$lockpath/calzip$seq.txt
+   lockfile=$lockpath/calzip${seq}-${telno}.txt
    checklock continue >> $scriptlog 2>&1
    query="UPDATE SequenceProcessStatus set fNotZipping=NULL WHERE fSequenceFirst=$seq"
