source: BAORadio/AmasNancay/trunk/statusdaq.sh @ 547

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

move to trunk the previous HEAD (jec)

File size: 2.0 KB
Line 
1#!/bin/sh
2#liste des "sources" enregistrees sous Amas
3GREP=/bin/grep
4AWK=/bin/awk
5ECHO=/bin/echo
6MKDIR=/bin/mkdir
7CAT=/bin/cat
8PRINTF=/usr/bin/printf
9LS=/bin/ls
10RM=/bin/rm
11SORT=/bin/sort
12XARGS=/usr/bin/xargs
13DefaultIFS=$' \t\n'
14IFS=$DefaultIFS
15
16
17# Irods environment settings
18. /usr/local/shared/bin/irods_env.sh -noverbose
19
20scriptName="`basename $0`"
21$ECHO "Processing script ${scriptName} at `date`"
22
23#Path to public backupable path
24publicpath="/afs/in2p3.fr/home/c/campagne/public"
25
26
27#temporary files to synchronize scripts
28tmppublicpath=${TMPPUBLICPATH}
29$LS -l ${tmppublicpath} > /dev/null
30
31
32#Path where the job will do temporary IO
33if [ ${ENVIRONMENT} == "INTERACTIVE" ]; then
34    iojobpath="/sps/baoradio/AmasNancay/JEC"
35    $MKDIR -p $iojobpath
36elif [ ${ENVIRONMENT} == "BATCH" ] ; then
37    iojobpath=${TMPBATCH}
38else
39    $ECHO "FATAL (${scriptName}): environment is ${ENVIRONMENT} not allowed"
40#JEC 29/9/11 avoid finished stuff
41#    touch ${tmppublicpath}/statusdaq.finished
42    exit 1
43fi
44cd ${iojobpath}
45
46
47OUT1=./baoils.$$
48ils /baoradio/data/AmasNancay/ > ${OUT1}
49OUT2=./baoawk1.$$
50$AWK '($1=="C-") {print $2}' ${OUT1} > ${OUT2}
51$RM $OUT1
52
53#Sequence
54tableau=( `$CAT $OUT2 | $AWK '{print $1}'` )
55IFS='
56'
57tableau=( $( $PRINTF "%s\n" "${tableau[@]}" | $AWK 'x[$0]++ == 0' ) )
58IFS=$DefaultIFS
59
60$RM $OUT2
61
62for i in ${tableau[@]}
63do
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
86done
87
88#JEC 29/9/11 avoid finished stuff
89#touch ${tmppublicpath}/statusdaq.finished
90exit 0
Note: See TracBrowser for help on using the repository browser.