source: BAORadio/AmasNancay/trunk/scaIsOk.sh @ 575

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

introduce SCRIPTPATH environment variable (jec)

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