[513] | 1 | #!/bin/sh |
---|
| 2 | #download SCA file, proceed to introspection, and upload results |
---|
| 3 | DATE=/bin/date |
---|
| 4 | GREP=/bin/grep |
---|
| 5 | AWK=/bin/awk |
---|
| 6 | ECHO=/bin/echo |
---|
| 7 | WC=/usr/bin/wc |
---|
| 8 | CAT=/bin/cat |
---|
| 9 | PRINTF=/usr/bin/printf |
---|
| 10 | MKDIR=/bin/mkdir |
---|
| 11 | RM=/bin/rm |
---|
| 12 | LS=/bin/ls |
---|
| 13 | DefaultIFS=$' \t\n' |
---|
| 14 | IFS=$DefaultIFS |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | #set Irods environment |
---|
| 18 | . /usr/local/shared/bin/irods_env.sh -noverbose |
---|
| 19 | |
---|
| 20 | scriptName="`basename $0`" |
---|
| 21 | $ECHO "Processing script ${scriptName} at `date`" |
---|
| 22 | |
---|
| 23 | #which source to analyse |
---|
| 24 | sourceRadio=$1 |
---|
| 25 | |
---|
| 26 | #Path to public backupable path |
---|
| 27 | publicpath="/afs/in2p3.fr/home/c/campagne/public" |
---|
| 28 | |
---|
| 29 | #temporary files to synchronize scripts |
---|
| 30 | tmppublicpath=${TMPPUBLICPATH} |
---|
| 31 | $LS -l ${tmppublicpath} > /dev/null |
---|
| 32 | |
---|
| 33 | |
---|
| 34 | #Path where the job will do temporary IO |
---|
| 35 | if [ ${ENVIRONMENT} = "INTERACTIVE" ]; then |
---|
| 36 | iojobpath="/sps/baoradio/AmasNancay/JEC" |
---|
| 37 | $MKDIR -p $iojobpath |
---|
| 38 | elif [ ${ENVIRONMENT} = "BATCH" ] ; then |
---|
| 39 | iojobpath=${TMPBATCH} |
---|
| 40 | else |
---|
| 41 | $ECHO "FATAL (${scriptName}): environment is ${ENVIRONMENT} not allowed" |
---|
| 42 | touch ${tmppublicpath}/scaIsOk.finished |
---|
| 43 | exit 1 |
---|
| 44 | fi |
---|
| 45 | cd ${iojobpath} |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | localpath="${sourceRadio}" |
---|
| 49 | $MKDIR -p ./${localpath} |
---|
| 50 | cd ./${localpath} |
---|
| 51 | |
---|
| 52 | |
---|
| 53 | #Path of the utility scripts |
---|
| 54 | scriptpath="/afs/in2p3.fr/home/c/campagne/private/work/AmasNancay" |
---|
| 55 | |
---|
| 56 | |
---|
[540] | 57 | #JEC 1/10/11 Use generic baodaqstatus name |
---|
[513] | 58 | #get the daq current irod status |
---|
[540] | 59 | #tag=`${DATE} +%F` |
---|
| 60 | #OUT1=${publicpath}/baodaqstatus-${tag}.txt |
---|
| 61 | #OUT1=${publicpath}/baodaqstatus-2011-09-11.txt |
---|
| 62 | OUT1=${publicpath}/baodaqstatus-current.txt |
---|
[513] | 63 | |
---|
[540] | 64 | |
---|
[513] | 65 | if [ ! -e ${OUT1} -o ! -r ${OUT1} ]; then |
---|
| 66 | $ECHO "FATAL (${scriptName}): ${OUT1} is missing or not readable..." |
---|
[540] | 67 | # touch ${tmppublicpath}/scaIsOk.finished |
---|
[513] | 68 | exit 1 |
---|
| 69 | fi |
---|
| 70 | |
---|
| 71 | if [ ! "<${sourceRadio}>" = "<>" ]; then |
---|
| 72 | $ECHO "You have selected sourceRadio = $sourceRadio" |
---|
| 73 | tableau=( `$GREP -i ${sourceRadio} ${OUT1} | $AWK '( NF==4 ) { print $2 }' ` ) |
---|
| 74 | else |
---|
| 75 | tableau=( `$CAT ${OUT1} | $GREP -i "baoradio" | $AWK '( NF==4 ) { print $2 }'` ) |
---|
| 76 | fi |
---|
| 77 | IFS=' |
---|
| 78 | ' |
---|
| 79 | tableau=( $( $PRINTF "%s\n" "${tableau[@]}" | $AWK 'x[$0]++ == 0' ) ) |
---|
| 80 | IFS=$DefaultIFS |
---|
| 81 | |
---|
| 82 | for i in ${tableau[@]} |
---|
| 83 | do |
---|
| 84 | #scrutinize irods directory |
---|
| 85 | #Nb: we do not care here if ILS returns non unique instance of a file |
---|
| 86 | scafile=`ils -l $i 2>&1 | $GREP -i "sca[0-9][0-9]*\.[0-9][0-9]*" | $AWK '{print $NF}'` |
---|
| 87 | if [ "<${scafile}>" = "<>" ]; then |
---|
| 88 | $ECHO "INFO (${scriptName}): Cannot download a SCA file for `basename $i`" |
---|
| 89 | fi |
---|
| 90 | done |
---|