source: BAORadio/AmasNancay/trunk/statusCycles.sh @ 547

Last change on this file since 547 was 547, checked in by campagne, 13 years ago

move to trunk the previous HEAD (jec)

  • Property svn:executable set to *
File size: 2.4 KB
Line 
1#!/bin/sh
2#liste des "sources" enregistrees sous Amas
3AWK=/bin/awk
4SED=/bin/sed
5GREP=/bin/grep
6WC=/usr/bin/wc
7RM=/bin/rm
8CAT=/bin/cat
9TOUCH=/bin/touch
10DATE=/bin/date
11ECHO=/bin/echo
12LS=/bin/ls
13MKDIR=/bin/mkdir
14TR=/usr/bin/tr
15FIND=/usr/bin/find
16PRINTF=/usr/bin/printf
17XARGS=/usr/bin/xargs
18SORT=/bin/sort
19QSUB=qsub
20
21DefaultIFS=$' \t\n'
22IFS=$DefaultIFS
23
24trim() { echo $1; }
25
26
27# Irods environment settings
28. /usr/local/shared/bin/irods_env.sh -noverbose
29
30scriptName="`basename $0`"
31$ECHO "Processing script ${scriptName} at `date`"
32
33#Path to public backupable path
34publicpath="/afs/in2p3.fr/home/c/campagne/public"
35
36
37#temporary files to synchronize scripts
38tmppublicpath=${TMPPUBLICPATH}
39$LS -l ${tmppublicpath} > /dev/null
40
41
42#Path where the job will do temporary IO
43if [ ${ENVIRONMENT} == "INTERACTIVE" ]; then
44    iojobpath="/sps/baoradio/AmasNancay/JEC"
45    $MKDIR -p $iojobpath
46elif [ ${ENVIRONMENT} == "BATCH" ] ; then
47    iojobpath=${TMPBATCH}
48else
49    $ECHO "FATAL (${scriptName}): environment is ${ENVIRONMENT} not allowed"
50    touch ${tmppublicpath}/statusdaq.finished
51    exit 1
52fi
53cd ${iojobpath}
54
55
56OUT1=./baoils.$$
57ils /baoradio/data/AmasNancay/ > ${OUT1}
58OUT2=./baoawk1.$$
59$AWK '($1=="C-") {print $2}' ${OUT1} > ${OUT2}
60$RM $OUT1
61#Sequence
62tableau=( `$CAT $OUT2 | $AWK '{print $1}'` )
63IFS='
64'
65tableau=( $( $PRINTF "%s\n" "${tableau[@]}" | $AWK 'x[$0]++ == 0' ) )
66IFS=$DefaultIFS
67
68$RM $OUT2
69
70for i in ${tableau[@]}
71do
72  OUT2=./baodir.$$
73  $ECHO "source $i"
74  listedate=( `ils $i | $AWK '($1=="C-"){print $2}'`)
75  IFS='
76'
77  listedate=( $( $PRINTF "%s\n" "${listedate[@]}" | $AWK 'x[$0]++ == 0' ) )
78  IFS=$DefaultIFS
79
80  for j in ${listedate[@]}
81  do
82    ils -l $j 2>&1 | $GREP -i "sca" > ${OUT2}
83#test if the SCA file has been already processed
84    scatrans=`$GREP -i "sca.*\.sum\.trans" ${OUT2} | $AWK '{print $NF}'`
85#test if the file is empty due to previous processing dysfunction
86    emptyfile=`$GREP -i "sca.*\.sum\.trans" ${OUT2} | $AWK '{print $4}'`
87#  echo "scrutinize directory <$i>: [$nblines] [$scatrans]"
88    if [ "<${scatrans}>" != "<>" ]; then
89        scafile=`$GREP -i "sca.*\.sum\.trans" ${OUT2} | $AWK '{print $NF}'`
90        if [ "<${scafile}>" = "<>" ]; then
91            $ECHO "WARNING (${scriptName}): Cannot download a SCA file for $j"
92        else
93#get sca file
94            iget -r -f -K ${j}/${scafile}
95            ncycle=`$CAT ${scafile} | $WC -l`
96            $RM ${scafile}
97            $ECHO ">>> $j ---> ${ncycle} cycles"
98        fi
99    else
100        $ECHO ">>> $j ---> NO SCA summary"
101    fi
102  done 
103  $RM ${OUT2}
104done
105
106
107
Note: See TracBrowser for help on using the repository browser.