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

Last change on this file since 7048 was 7048, checked in by Daniela Dorner, 19 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.4 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
29source /home/operator/Mars/datacenter/scripts/sourcefile
30
31table=SequenceProcessStatus
32column=fAllFilesAvail
33date=NULL
34datetime=`date +%F-%H-%M-%S`
35year=`date +%Y`
36
37todofile=/magic/datacenter/lists/ToDo-$table-$column.txt
38getstatuslogpath=$logpath/getstatus/checkfileavail/$year
39getstatuslog=$getstatuslogpath/getstatus-$table-$column-$datetime.log
40
41scriptlogpath=$logpath/run/checkfilesavail/`date +%Y/%m/%d`
42if [ ! -d $scriptlogpath ]
43then
44 mkdir -pv $scriptlogpath
45 if [ ! -d $scriptlogpath ]
46 then
47 echo "could not make scriptlogpath "$scriptlogpath
48 exit
49 fi
50fi
51
52scriptlog=$scriptlogpath/checkfilesforsequenceavail-$datetime.log
53
54date >> $scriptlog 2>&1
55
56if [ ! -d $getstatuslogpath ]
57then
58 mkdir -pv $getstatuslogpath >> $scriptlog 2>&1
59 if [ ! -d $getstatuslogpath ]
60 then
61 echo "could not make getstatuslogpath "$getstatuslogpath >> $scriptlog 2>&1
62 exit
63 fi
64fi
65
66cd $mars
67
68if [ -e $todofile ]
69then
70 echo "checkfilesforsequenceavail is already running -> exit" >> $scriptlog 2>&1
71 exit
72fi
73
74echo "getting list..." >> $scriptlog 2>&1
75check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
76
77case $check0 in
78 1) echo "check0=$check0 -> everthing ok -> do step" >> $scriptlog 2>&1 ;;
79 *) echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1 ;;
80esac
81
82sequences=(`cat $todofile`)
83
84if [ "$sequences" = "" ]
85then
86 echo "nothing to do -> exit" >> $scriptlog 2>&1
87 rm -v $todofile >> $scriptlog 2>&1
88 rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
89 date >> $scriptlog 2>&1
90 exit
91fi
92
93echo "sequences: "${sequences[@]} >> $scriptlog 2>&1
94
95for sequence in ${sequences[@]}
96do
97 echo "checking files for sequence $sequence..." >> $scriptlog 2>&1
98 no=`printf %08d $sequence | cut -c 0-4`
99 outpath=$logpath/checkfileavail/$no
100 echo "outpath: "$outpath >> $scriptlog 2>&1
101 if [ ! -d $outpath ]
102 then
103 mkdir -pv $outpath >> $scriptlog 2>&1
104 if [ ! -d $outpath ]
105 then
106 echo "could not make outpath $outpath -> continue " >> $scriptlog 2>&1
107 continue
108 fi
109 fi
110 check1=`root -q -b $macrospath/checkfileavail.C+\(\""$sequence\""\) | tee $outpath/checkfileavail-$sequence.log | grep int | sed -e 's/(int)//'`
111
112 case $check1 in
113 1) echo "check1=$check1 -> everthing ok -> setting status..." >> $scriptlog 2>&1
114 setstatuslogpath=$logpath/setstatus/checkfileavail/$no
115 if [ ! -d $setstatuslogpath ]
116 then
117 mkdir -pv $setstatuslogpath >> $scriptlog 2>&1
118 if [ ! -d $setstatuslogpath ]
119 then
120 echo "could not make setstatuslogpath "$setstatuslogpath >> $scriptlog 2>&1
121 continue
122 fi
123 fi
124 check2=`root -q -b $macrospath/setstatus.C+\("\"$sequence\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuslogpath/setstatus-checkfileavail-$sequence.log | grep int | sed -e 's/(int)//'`
125 case $check2 in
126 1) echo "check2=$check2 -> everthing ok, status has been set" >> $scriptlog 2>&1 ;;
127 *) echo "check2=$check2 -> ERROR -> step could not be set" >> $scriptlog 2>&1 ;;
128 esac
129 ;;
130 *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1 ;;
131 esac
132done
133
134rm -v $todofile >> $scriptlog 2>&1
135rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
136
137date >> $scriptlog 2>&1
138
Note: See TracBrowser for help on using the repository browser.