source: BAORadio/AmasNancay/trunk/statuscalib.sh @ 637

Last change on this file since 637 was 595, checked in by torrento, 13 years ago

Comment sleep in while loop

File size: 3.4 KB
Line 
1#!/bin/sh
2#Status de l'etat de la production des fichiers INPUT de calibrations
3GREP=/bin/grep
4AWK=/bin/awk
5ECHO=/bin/echo
6MKDIR=/bin/mkdir
7CAT=/bin/cat
8PRINTF=/usr/bin/printf
9RM=/bin/rm
10SORT=/bin/sort
11XARGS=/usr/bin/xargs
12WC=/usr/bin/wc
13DefaultIFS=$' \t\n'
14IFS=$DefaultIFS
15
16# Irods environment settings
17. /usr/local/shared/bin/irods_env.sh -noverbose
18
19scriptName="`basename $0`"
20$ECHO "Processing script ${scriptName} at `date`"
21
22#Path to public backupable path
23publicpath="/afs/in2p3.fr/home/c/campagne/public"
24
25#Path where the job will do temporary IO
26. ${SCRIPTPATH}/set_iojobpath.sh
27iojobpath=$(set_iojobpath)
28cd ${iojobpath}
29
30
31OUT1=./baoils.$$
32ils /baoradio/data/AmasNancay/ > ${OUT1}
33OUT2=./baoawk1.$$
34$AWK '($1=="C-") {print $2}' ${OUT1} > ${OUT2}
35$RM $OUT1
36#Sequence
37listeSources=( `$CAT $OUT2 | $AWK '{print $1}'` )
38IFS='
39'
40listeSources=( $( $PRINTF "%s\n" "${listeSources[@]}" | $AWK 'x[$0]++ == 0' ) )
41IFS=$DefaultIFS
42$RM $OUT2
43
44for i in ${listeSources[@]}
45do
46#nb: $i contains the full path
47  $ECHO "source ${i}"
48  sourceName=`basename ${i}`
49  listeDates=( `ils $i | $AWK '($1=="C-"){print $2}'`)
50  IFS='
51'
52  listeDates=( $( $PRINTF "%s\n" "${listeDates[@]}" | $AWK 'x[$0]++ == 0' ) )
53  IFS=$DefaultIFS
54
55  for j in ${listeDates[@]}
56  do
57#nb: $j contains the full path
58#  $ECHO "run ${j}"
59#
60#Off directory
61#
62    dateField=`basename ${j}`
63    sourceDate="${sourceName}-${dateField}"
64#look if final calibration files exist
65    calibOk=`ils ${j} | $GREP -i "calib_" | $WC -l`
66
67    offDirExist=`ils ${j} | $GREP -i "Off" | $WC -l`
68    if [ ${offDirExist} != 0 ]; then
69        listeCyclesOff=( `ils ${j}/Off | $GREP -i "calibcycle" | $AWK '($1=="C-"){print $2}' | $XARGS -i basename {} | $SORT -k1.11n` )
70        IFS='
71  '
72        listeCyclesOff=( $( $PRINTF "%s\n" "${listeCyclesOff[@]}" | $AWK 'x[$0]++ == 0' ) )
73        IFS=$DefaultIFS
74       
75        if [ ${#listeCyclesOff[*]} != 0 ]; then   
76           for c in ${listeCyclesOff[@]}
77           do
78#nb: $c has the format of calibcycle<number>
79             nFiles=`ils ${j}/Off/${c} | $GREP -i "medfiltmtx" | $WC -l`
80             if [ ${nFiles} != 0 ]; then
81                 $ECHO "${sourceDate}/Off/${c}: ${nFiles} spectra (${calibOk} calib)"
82             else
83                 $ECHO "${sourceDate}/Off/${c}: Calibration failed"
84             fi
85#end of loop on cycles
86           done
87        else
88            $ECHO "${sourceDate} : No Calibration done for Off Directory"
89        fi
90#end of Off exist
91    else
92        $ECHO "${sourceDate} : No Off Directory"
93    fi
94#
95#On directory
96#
97    dateField=`basename ${j}`
98    sourceDate="${sourceName}-${dateField}"
99#look if final calibration files exist
100    calibOk=`ils ${j} | $GREP -i "calib_" | $WC -l`
101    onDirExist=`ils ${j} | $GREP -i "On" | $WC -l`
102    if [ ${onDirExist} != 0 ]; then
103        listeCyclesOn=( `ils ${j}/On | $GREP -i "calibcycle" | $AWK '($1=="C-"){print $2}' | $XARGS -i basename {} | $SORT -k1.11n` )
104        IFS='
105  '
106        listeCyclesOn=( $( $PRINTF "%s\n" "${listeCyclesOn[@]}" | $AWK 'x[$0]++ == 0' ) )
107        IFS=$DefaultIFS
108       
109        if [ ${#listeCyclesOn[*]} != 0 ]; then   
110           for c in ${listeCyclesOn[@]}
111           do
112#nb: $c has the format of calibcycle<number>
113             nFiles=`ils ${j}/On/${c} | $GREP -i "medfiltmtx" | $WC -l`
114             if [ ${nFiles} != 0 ]; then
115                 $ECHO "${sourceDate}/On/${c}: ${nFiles} spectra (${calibOk} calib)"
116             else
117                 $ECHO "${sourceDate}/On/${c}: Calibration failed"
118             fi
119#end of loop on cycles
120           done
121        else
122            $ECHO "${sourceDate} : No Calibration done for On Directory"
123        fi
124#end of On exist
125    else
126        $ECHO "${sourceDate} : No On Directory"
127    fi
128#end of loop on dates
129  done 
130#end of loop on sources
131done
Note: See TracBrowser for help on using the repository browser.