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