source: trunk/MagicSoft/Mars/datacenter/scripts/checkfilesforsequenceavail@ 6934

Last change on this file since 6934 was 6934, checked in by Daniela Dorner, 19 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.5 KB
Line 
1#!/bin/sh
2#
3# ========================================================================
4#
5# *
6# * This file is part of MARS, the MAGIC Analysis and Reconstruction
7# * Software. It is distributed to you in the hope that it can be a useful
8# * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
9# * It is distributed WITHOUT ANY WARRANTY.
10# *
11# * Permission to use, copy, modify and distribute this software and its
12# * documentation for any purpose is hereby granted without fee,
13# * provided that the above copyright notice appear in all copies and
14# * that both that copyright notice and this permission notice appear
15# * in supporting documentation. It is provided "as is" without express
16# * or implied warranty.
17# *
18#
19#
20# Author(s): Daniela Dorner 08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
21#
22# Copyright: MAGIC Software Development, 2000-2004
23#
24#
25# ========================================================================
26#
27#
28
29export ROOTSYS=/opt/root_v3.10.02
30export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ROOTSYS/lib
31export PATH=$PATH:$ROOTSYS/bin
32
33mars=/home/operator/Mars
34macrospath=$mars/datacenter/macros
35
36table=SequenceProcessStatus
37column=fAllFilesAvail
38date=NULL
39datetime=`date +%F-%H-%M-%S`
40year=`date +%Y`
41
42todofile=/magic/datacenter/lists/ToDo-$table-$column.txt
43logpath=/magic/datacenter/autologs
44getstatuslogpath=$logpath/getstatus/checkfileavail/$year
45getstatuslog=$getstatuslogpath/getstatus-$table-$column-$datetime.log
46
47scriptlogpath=$logpath/run/checkfilesavail/`date +%Y/%m/%d`
48if [ ! -d $scriptlogpath ]
49then
50 mkdir -pv $scriptlogpath
51 if [ ! -d $scriptlogpath ]
52 then
53 echo "could not make scriptlogpath "$scriptlogpath
54 exit
55 fi
56fi
57
58scriptlog=$scriptlogpath/checkfilesforsequenceavail-$datetime.log
59
60date >> $scriptlog 2>&1
61
62if [ ! -d $getstatuslogpath ]
63then
64 mkdir -pv $getstatuslogpath >> $scriptlog 2>&1
65 if [ ! -d $getstatuslogpath ]
66 then
67 echo "could not make getstatuslogpath "$getstatuslogpath >> $scriptlog 2>&1
68 exit
69 fi
70fi
71
72cd $mars
73
74if [ -e $todofile ]
75then
76 echo "checkfilesforsequenceavail is already running -> exit" >> $scriptlog 2>&1
77 exit
78fi
79
80echo "getting list..." >> $scriptlog 2>&1
81check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
82
83case $check0 in
84 1) echo "check0=$check0 -> everthing ok -> do step" >> $scriptlog 2>&1 ;;
85 *) echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1 ;;
86esac
87
88sequences=(`cat $todofile`)
89
90if [ "$sequences" = "" ]
91then
92 echo "nothing to do -> exit" >> $scriptlog 2>&1
93 rm -v $todofile >> $scriptlog 2>&1
94 rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
95 date >> $scriptlog 2>&1
96 exit
97fi
98
99echo "sequences: "${sequences[@]} >> $scriptlog 2>&1
100
101for sequence in ${sequences[@]}
102do
103 echo "checking files for sequence $sequence..." >> $scriptlog 2>&1
104 no=`printf %08d $sequence | cut -c 4`
105 outpath=$logpath/checkfileavail/`printf %04d $no`
106 echo "outpath: "$outpath >> $scriptlog 2>&1
107 if [ ! -d $outpath ]
108 then
109 mkdir -pv $outpath >> $scriptlog 2>&1
110 if [ ! -d $outpath ]
111 then
112 echo "could not make outpath $outpath -> continue " >> $scriptlog 2>&1
113 continue
114 fi
115 fi
116 check1=`root -q -b $macrospath/checkfileavail.C+\(\""$sequence\""\) | tee $outpath/checkfileavail-$sequence.log | grep int | sed -e 's/(int)//'`
117
118 case $check1 in
119 1) echo "check1=$check1 -> everthing ok -> setting status..." >> $scriptlog 2>&1
120 setstatuslogpath=$logpath/setstatus/checkfileavail/`printf %04d $no`
121 if [ ! -d $setstatuslogpath ]
122 then
123 mkdir -pv $setstatuslogpath >> $scriptlog 2>&1
124 if [ ! -d $setstatuslogpath ]
125 then
126 echo "could not make setstatuslogpath "$setstatuslogpath >> $scriptlog 2>&1
127 continue
128 fi
129 fi
130 check2=`root -q -b $macrospath/setstatus.C+\("\"$sequence\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuslogpath/setstatus-checkfileavail-$sequence.log | grep int | sed -e 's/(int)//'`
131 case $check2 in
132 1) echo "check2=$check2 -> everthing ok, status has been set" >> $scriptlog 2>&1 ;;
133 *) echo "check2=$check2 -> ERROR -> step could not be set" >> $scriptlog 2>&1 ;;
134 esac
135 ;;
136 *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1 ;;
137 esac
138done
139
140rm -v $todofile >> $scriptlog 2>&1
141rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
142
143date >> $scriptlog 2>&1
144
Note: See TracBrowser for help on using the repository browser.