[507] | 1 | #!/bin/sh |
---|
| 2 | #liste des "sources" enregistrees sous Amas |
---|
| 3 | GREP=/bin/grep |
---|
| 4 | AWK=/bin/awk |
---|
| 5 | ECHO=/bin/echo |
---|
| 6 | MKDIR=/bin/mkdir |
---|
| 7 | CAT=/bin/cat |
---|
| 8 | PRINTF=/usr/bin/printf |
---|
| 9 | LS=/bin/ls |
---|
| 10 | RM=/bin/rm |
---|
| 11 | SORT=/bin/sort |
---|
| 12 | XARGS=/usr/bin/xargs |
---|
| 13 | DefaultIFS=$' \t\n' |
---|
| 14 | IFS=$DefaultIFS |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | # Irods environment settings |
---|
| 18 | . /usr/local/shared/bin/irods_env.sh -noverbose |
---|
| 19 | |
---|
| 20 | scriptName="`basename $0`" |
---|
| 21 | $ECHO "Processing script ${scriptName} at `date`" |
---|
| 22 | |
---|
| 23 | #Path to public backupable path |
---|
| 24 | publicpath="/afs/in2p3.fr/home/c/campagne/public" |
---|
| 25 | |
---|
| 26 | |
---|
| 27 | #temporary files to synchronize scripts |
---|
[516] | 28 | tmppublicpath=${TMPPUBLICPATH} |
---|
[507] | 29 | $LS -l ${tmppublicpath} > /dev/null |
---|
| 30 | |
---|
| 31 | |
---|
| 32 | #Path where the job will do temporary IO |
---|
| 33 | if [ ${ENVIRONMENT} == "INTERACTIVE" ]; then |
---|
| 34 | iojobpath="/sps/baoradio/AmasNancay/JEC" |
---|
| 35 | $MKDIR -p $iojobpath |
---|
| 36 | elif [ ${ENVIRONMENT} == "BATCH" ] ; then |
---|
| 37 | iojobpath=${TMPBATCH} |
---|
| 38 | else |
---|
| 39 | $ECHO "FATAL (${scriptName}): environment is ${ENVIRONMENT} not allowed" |
---|
[540] | 40 | #JEC 29/9/11 avoid finished stuff |
---|
| 41 | # touch ${tmppublicpath}/statusdaq.finished |
---|
[507] | 42 | exit 1 |
---|
| 43 | fi |
---|
| 44 | cd ${iojobpath} |
---|
| 45 | |
---|
| 46 | |
---|
| 47 | OUT1=./baoils.$$ |
---|
| 48 | ils /baoradio/data/AmasNancay/ > ${OUT1} |
---|
| 49 | OUT2=./baoawk1.$$ |
---|
| 50 | $AWK '($1=="C-") {print $2}' ${OUT1} > ${OUT2} |
---|
| 51 | $RM $OUT1 |
---|
| 52 | |
---|
| 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 | $ECHO "source $i" |
---|
| 65 | listedate=( `ils $i | $AWK '($1=="C-"){print $2}'`) |
---|
| 66 | IFS=' |
---|
| 67 | ' |
---|
| 68 | listedate=( $( $PRINTF "%s\n" "${listedate[@]}" | $AWK 'x[$0]++ == 0' ) ) |
---|
| 69 | IFS=$DefaultIFS |
---|
| 70 | |
---|
| 71 | ntotfiles=0 |
---|
| 72 | for j in ${listedate[@]} |
---|
| 73 | do |
---|
| 74 | #Nb: care should be taken to the possible instances of a file returned by ILS |
---|
| 75 | listOfsig=( `ils ${j}/Fiber1 | $GREP -i "signal" | $XARGS -i basename {} | $SORT -k1.7n` ) |
---|
| 76 | IFS=' |
---|
| 77 | ' |
---|
| 78 | listOfsig=( $( $PRINTF "%s\n" "${listOfsig[@]}" | $AWK 'x[$0]++ == 0' ) ) |
---|
| 79 | IFS=$DefaultIFS |
---|
| 80 | nfiles=${#listOfsig[@]} |
---|
| 81 | $ECHO ">>> $j ---> $nfiles" |
---|
| 82 | let "ntotfiles=ntotfiles+nfiles" |
---|
| 83 | done |
---|
| 84 | $ECHO "total files = $ntotfiles" |
---|
| 85 | |
---|
| 86 | done |
---|
| 87 | |
---|
[540] | 88 | #JEC 29/9/11 avoid finished stuff |
---|
| 89 | #touch ${tmppublicpath}/statusdaq.finished |
---|
[507] | 90 | exit 0 |
---|