1 | #!/bin/sh
|
---|
2 | #Get SCA file and summary + transformed date file
|
---|
3 | #
|
---|
4 | DATE=/bin/date
|
---|
5 | GREP=/bin/grep
|
---|
6 | AWK=/bin/awk
|
---|
7 | ECHO=/bin/echo
|
---|
8 | TR=/usr/bin/tr
|
---|
9 | MKDIR=/bin/mkdir
|
---|
10 | CAT=/bin/cat
|
---|
11 | PRINTF=/usr/bin/printf
|
---|
12 | RM=/bin/rm
|
---|
13 | LS=/bin/ls
|
---|
14 | DefaultIFS=$' \t\n'
|
---|
15 | IFS=$DefaultIFS
|
---|
16 |
|
---|
17 | scriptName="`basename $0`"
|
---|
18 | $ECHO "Processing script ${scriptName} at `date`"
|
---|
19 |
|
---|
20 |
|
---|
21 | if [ ! $# = 2 ]; then
|
---|
22 | $ECHO "usage: ${script
|
---|
23 | Name} <source:ex. Abell85> <date:YYYYMMDD>"
|
---|
24 | exit 0
|
---|
25 | fi
|
---|
26 |
|
---|
27 | # Irods environment settings
|
---|
28 | #export PATH=$PATH:/home/bao/irods2.5_LinuxSL5
|
---|
29 | . /usr/local/shared/bin/irods_env.sh -noverbose
|
---|
30 |
|
---|
31 |
|
---|
32 | sourceRadio=$1
|
---|
33 | srclower=`${ECHO} ${sourceRadio} | ${TR} "[:upper:]" "[:lower:]" `
|
---|
34 | dateDAQ=$2
|
---|
35 |
|
---|
36 |
|
---|
37 | #Path to public backupable path
|
---|
38 | publicpath="/afs/in2p3.fr/home/c/campagne/public"
|
---|
39 |
|
---|
40 | #temporary files to synchronize scripts
|
---|
41 | tmppublicpath=${TMPPUBLICPATH}
|
---|
42 | $LS -l ${tmppublicpath} > /dev/null
|
---|
43 |
|
---|
44 |
|
---|
45 | #Path where the job will do temporary IO
|
---|
46 | . ${SCRIPTPATH}/set_iojobpath.sh
|
---|
47 | iojobpath=$(set_iojobpath)
|
---|
48 | cd ${iojobpath}
|
---|
49 |
|
---|
50 | localpath="${sourceRadio}/${dateDAQ}${srclower}"
|
---|
51 | $MKDIR -p ./${localpath}
|
---|
52 | cd ./${localpath}
|
---|
53 |
|
---|
54 |
|
---|
55 | #Path of the utility scripts
|
---|
56 | scriptpath=${SCRIPTPATH}
|
---|
57 |
|
---|
58 | #JEC 1/10/11 Use generic baodaqstatus name
|
---|
59 | #look if the run exists
|
---|
60 | #tag=`${DATE} +%F`
|
---|
61 | #OUT1=${publicpath}/baodaqstatus-${tag}.txt
|
---|
62 | OUT1=${publicpath}/baodaqstatus-current.txt
|
---|
63 |
|
---|
64 | if [ ! -e ${OUT1} -o ! -r ${OUT1} ]; then
|
---|
65 | # $ECHO "We should bring the DAQ status more up to date, this take 1 or 2sec..."
|
---|
66 | # $RM -f ${tmppublicpath}/statusdaq.finished
|
---|
67 | # ${scriptpath}/statusdaq.sh > ${OUT1}
|
---|
68 | # while [ ! -f "${tmppublicpath}/statusdaq.finished" ]; do
|
---|
69 | # $ECHO "INFO (${scriptName}); waiting for ${tmppublicpath}/statusdaq.finished"
|
---|
70 | # date +%T
|
---|
71 | # sleep 30
|
---|
72 | # done
|
---|
73 | # $RM ${tmppublicpath}/statusdaq.finished
|
---|
74 | $ECHO "FATAL (${scriptName}): ${OUT1} is missing or not readable..."
|
---|
75 | exit 1
|
---|
76 | fi
|
---|
77 |
|
---|
78 | nfiles=`${GREP} "${sourceRadio}.*${dateDAQ}" ${OUT1} | ${AWK} '(NF==4){print $4}'`
|
---|
79 |
|
---|
80 | if [ "<${nfiles}>" = "<>" ]; then
|
---|
81 | $ECHO "FATAL (${scriptName}): No run found for <${sourceRadio}> and date <${dateDAQ}>"
|
---|
82 | exit 1
|
---|
83 | fi
|
---|
84 |
|
---|
85 |
|
---|
86 | #Look if the run should/can be prepared wrt SCA file transformation
|
---|
87 | OUT2=./scaStatus.$$
|
---|
88 | #JEC 29/9/11 avoid finished stuff
|
---|
89 | #$RM -f ${tmppublicpath}/scaextractor.finished
|
---|
90 | ${scriptpath}/scaextractor.sh $sourceRadio > ${OUT2} 2>&1
|
---|
91 | #while [ ! -f "${tmppublicpath}/scaextractor.finished" ]; do
|
---|
92 | # $ECHO "INFO (${scriptName}); waiting for ${tmppublicpath}/scaextractor.finished"
|
---|
93 | # date +%T
|
---|
94 | # sleep 30
|
---|
95 | #done
|
---|
96 | #$RM ${tmppublicpath}/scaextractor.finished
|
---|
97 |
|
---|
98 |
|
---|
99 | status=`$GREP "^FATAL.*${sourceRadio}.*${dateDAQ}" ${OUT2}`
|
---|
100 |
|
---|
101 | if [ "<$status>" != "<>" ]; then
|
---|
102 | $ECHO "FATAL (${scriptName}): connot proceed further with $sourceRadio $dateDAQ"
|
---|
103 | exit 1
|
---|
104 | fi
|
---|
105 | $RM $OUT2
|
---|
106 |
|
---|
107 | #dowload sca files...
|
---|
108 | dirIrod="/baoradio/data/AmasNancay/${sourceRadio}/${dateDAQ}${srclower}"
|
---|
109 | dirLocal="."
|
---|
110 |
|
---|
111 | if [ ! -e $dirLocal ]; then
|
---|
112 | $MKDIR -p $dirLocal
|
---|
113 | fi
|
---|
114 |
|
---|
115 | cd $dirLocal
|
---|
116 |
|
---|
117 | OUT3=./scaFiles.$$
|
---|
118 | ils $dirIrod | $GREP -i "sca" > ${OUT3}
|
---|
119 | tableau=( `$CAT ${OUT3}` )
|
---|
120 | IFS='
|
---|
121 | '
|
---|
122 | tableau=( $( $PRINTF "%s\n" "${tableau[@]}" | $AWK 'x[$0]++ == 0' ) )
|
---|
123 | IFS=$DefaultIFS
|
---|
124 | $RM $OUT3
|
---|
125 |
|
---|
126 | OUT4=./igetStatus.$$
|
---|
127 | for i in ${tableau[@]}
|
---|
128 | do
|
---|
129 | if [ ! -e $i ]; then
|
---|
130 | iget -r -f -v -K ${dirIrod}/$i ${dirLocal} > ${OUT4} 2>&1
|
---|
131 | fi
|
---|
132 | done
|
---|
133 |
|
---|
134 | igetStatus=`$GREP "^ERROR" ${OUT4}`
|
---|
135 | if [ "<$igetStatus>" != "<>" ]; then
|
---|
136 | $ECHO "FATAL (${scriptName}): error while iget:"
|
---|
137 | $ECHO $igetStatus
|
---|
138 | exit 1
|
---|
139 | fi
|
---|
140 |
|
---|
141 | $RM -f $OUT4
|
---|
142 |
|
---|
143 | exit 0
|
---|