#!/bin/sh #download SCA file, proceed to introspection, and upload results DATE=/bin/date GREP=/bin/grep AWK=/bin/awk ECHO=/bin/echo WC=/usr/bin/wc CAT=/bin/cat PRINTF=/usr/bin/printf MKDIR=/bin/mkdir RM=/bin/rm LS=/bin/ls DefaultIFS=$' \t\n' IFS=$DefaultIFS #set Irods environment . /usr/local/shared/bin/irods_env.sh -noverbose scriptName="`basename $0`" $ECHO "Processing script ${scriptName} at `date`" #which source to analyse sourceRadio=$1 #Path to public backupable path publicpath="/afs/in2p3.fr/home/c/campagne/public" #temporary files to synchronize scripts tmppublicpath=${TMPPUBLICPATH} $LS -l ${tmppublicpath} > /dev/null #Path where the job will do temporary IO . ${SCRIPTPATH}/set_iojobpath.sh iojobpath=$(set_iojobpath) cd ${iojobpath} localpath="${sourceRadio}" $MKDIR -p ./${localpath} cd ./${localpath} #Path of the utility scripts scriptpath=${SCRIPTPATH} #JEC 1/10/11 Use generic baodaqstatus name #get the daq current irod status #tag=`${DATE} +%F` #OUT1=${publicpath}/baodaqstatus-${tag}.txt #OUT1=${publicpath}/baodaqstatus-2011-09-11.txt OUT1=${publicpath}/baodaqstatus-current.txt if [ ! -e ${OUT1} -o ! -r ${OUT1} ]; then $ECHO "FATAL (${scriptName}): ${OUT1} is missing or not readable..." exit 1 fi if [ ! "<${sourceRadio}>" = "<>" ]; then $ECHO "You have selected sourceRadio = $sourceRadio" tableau=( `$GREP -i ${sourceRadio} ${OUT1} | $AWK '( NF==4 ) { print $2 }' ` ) else tableau=( `$CAT ${OUT1} | $GREP -i "baoradio" | $AWK '( NF==4 ) { print $2 }'` ) fi IFS=' ' tableau=( $( $PRINTF "%s\n" "${tableau[@]}" | $AWK 'x[$0]++ == 0' ) ) IFS=$DefaultIFS for i in ${tableau[@]} do #scrutinize irods directory #Nb: we do not care here if ILS returns non unique instance of a file scafile=`ils -l $i 2>&1 | $GREP -i "sca[0-9][0-9]*\.[0-9][0-9]*" | $AWK '{print $NF}'` if [ "<${scafile}>" = "<>" ]; then $ECHO "INFO (${scriptName}): Cannot download a SCA file for `basename $i`" fi done