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

Last change on this file since 579 was 579, checked in by torrento, 13 years ago

version adaptee a grid engin (ana)

  • Property svn:executable set to *
File size: 1.9 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
35. ${SCRIPTPATH}/set_iojobpath.sh
36iojobpath=$(set_iojobpath)
37cd ${iojobpath}
38
39
40localpath="${sourceRadio}"
41$MKDIR -p ./${localpath}
42cd ./${localpath}
43
44
45#Path of the utility scripts
46scriptpath=${SCRIPTPATH}
47
48
49#JEC 1/10/11 Use generic baodaqstatus name
50#get the daq current irod status
51#tag=`${DATE} +%F`
52#OUT1=${publicpath}/baodaqstatus-${tag}.txt
53#OUT1=${publicpath}/baodaqstatus-2011-09-11.txt
54OUT1=${publicpath}/baodaqstatus-current.txt
55
56
57if [ ! -e ${OUT1} -o ! -r ${OUT1} ]; then
58    $ECHO "FATAL (${scriptName}): ${OUT1} is missing or not readable..."
59    exit 1
60fi
61
62if [ ! "<${sourceRadio}>" = "<>" ]; then
63    $ECHO "You have selected sourceRadio = $sourceRadio"
64    tableau=( `$GREP -i ${sourceRadio} ${OUT1} | $AWK '( NF==4 ) { print $2 }' ` )
65else
66    tableau=( `$CAT ${OUT1} | $GREP -i "baoradio" | $AWK '( NF==4 ) { print $2 }'`  )
67fi
68IFS='
69'
70tableau=( $( $PRINTF "%s\n" "${tableau[@]}" | $AWK 'x[$0]++ == 0' ) )
71IFS=$DefaultIFS
72
73for i in ${tableau[@]}
74do
75#scrutinize irods directory
76#Nb: we do not care here if ILS returns non unique instance of a file
77  scafile=`ils -l $i 2>&1 | $GREP -i "sca[0-9][0-9]*\.[0-9][0-9]*" | $AWK '{print $NF}'`
78  if [ "<${scafile}>" = "<>" ]; then
79      $ECHO "INFO (${scriptName}): Cannot download a SCA file for `basename $i`"
80  fi
81done
Note: See TracBrowser for help on using the repository browser.