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

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