source: BAORadio/AmasNancay/getDiffRawOnOff.sh @ 543

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

util to download ppf file for final analysis (jec)

  • Property svn:executable set to *
File size: 3.2 KB
Line 
1#!/bin/sh -xvf
2#Perform the ON-OFF analysis
3DATE=/bin/date
4GREP=/bin/grep
5AWK=/bin/awk
6ECHO=/bin/echo
7WC=/usr/bin/wc
8CAT=/bin/cat
9PRINTF=/usr/bin/printf
10FIND=/usr/bin/find
11MKDIR=/bin/mkdir
12XARGS=/usr/bin/xargs
13SORT=/bin/sort
14RM=/bin/rm
15TR=/usr/bin/tr
16CP=/bin/cp
17LS=/bin/ls
18CHMOD=/bin/chmod
19
20DefaultIFS=$' \t\n'
21IFS=$DefaultIFS
22
23#set Irods environment   
24. /usr/local/shared/bin/irods_env.sh -noverbose
25
26scriptName="`basename $0`"
27$ECHO "Processing script ${scriptName} at `date`"
28#which source to analyse
29
30#Process cmd line args: the -src option is mandatory (source name as Abell85)
31sourceRadio=
32dateSelected=
33simulationMode=Off
34while [ $# -gt 0 ]
35  do
36  case "$1" in
37      -src)  sourceRadio=$2;    shift;;
38      -date) dateSelected=$2;     shift;;
39      -sim)  simulationMode=On;;
40      -h)
41      echo >&2 \
42          "usage: $0 -src souce -date YYYYMMDD [-sim to trig simulation mode]"
43      exit 1;;
44      *)  break;;       # terminate while loop
45  esac
46  shift
47done
48
49
50if [ ${simulationMode} = "On" ]; then
51    $ECHO "INFO ${scriptName} running in SIMUL mode"
52fi
53
54if [ "<${sourceRadio}>" = "<>" ]; then
55    $ECHO "FATAL: You have forgotten to select the source option (-src)"
56    exit 1
57fi
58
59case ${sourceRadio} in
60    Abell85) $ECHO "INFO (${scriptName}): process ${sourceRadio}";;
61    Abell2440) $ECHO "INFO (${scriptName}): process ${sourceRadio}";;
62    Abell1205) $ECHO "INFO (${scriptName}): process ${sourceRadio}";;
63    *) ECHO "FATAL (${scriptName}): process ${sourceRadio} not yet foreseen"
64    exit 1;;
65esac
66
67srclower=`${ECHO} ${sourceRadio} | ${TR} "[:upper:]" "[:lower:]" `
68
69#Path to public backupable path
70publicpath="/afs/in2p3.fr/home/c/campagne/public"
71
72
73#temporary files to synchronize scripts
74tmppublicpath=${TMPPUBLICPATH}
75#wakeup the NFS disk
76$LS -l ${tmppublicpath} > /dev/null
77
78#Path where the job will do temporary IO
79if [ ${ENVIRONMENT} = "INTERACTIVE" ]; then
80    iojobpath="/sps/baoradio/AmasNancay/JEC"
81    $MKDIR -p $iojobpath
82else
83    $ECHO "FATAL (${scriptName}): environment is ${ENVIRONMENT} not allowed"
84    exit 1
85fi
86cd ${iojobpath}
87
88localpath="${sourceRadio}"
89$MKDIR -p ./${localpath}
90cd ./${localpath}
91
92
93#Path of the utility scripts
94scriptpath="/afs/in2p3.fr/home/c/campagne/private/work/AmasNancay"
95
96OUT1=${publicpath}/baodaqstatus-current.txt
97if [ ! -e ${OUT1}  -o ! -r ${OUT1} ]; then
98    $ECHO "FATAL (${scriptName}): ${OUT1} has a problem"
99    exit 1
100fi
101
102
103
104$ECHO "You have selected sourceRadio = ${sourceRadio} [date = ${dateSelected}]"
105tableau=( `$GREP -i "${dateSelected}${srclower}" ${OUT1} | $AWK '( NF==4 ) { print $2 }' ` )
106IFS='
107' 
108tableau=( $( $PRINTF "%s\n" "${tableau[@]}" | $AWK 'x[$0]++ == 0' ) )
109IFS=$DefaultIFS
110
111$ECHO "We are in directory `pwd`"
112
113for i in ${tableau[@]}
114  do
115#
116 
117  $ECHO "DEBUG: (${scriptName}) irods root dir $i"
118#  dateDAQ=`$ECHO ${i} | $AWK '{split($0,a,"/"); print a[6];}' | $AWK "{sub(/${srclower}/,\"\"); print}"`
119
120  file=`ils ${i} 2>&1 | $GREP -i "diffOnOffRAw_.*\.ppf"`
121  file=`$ECHO $file`
122  if [ "<${file}>" != "<>" ]; then
123      if [ ! -e ${file}  ]; then
124          iget -f -v ${i}/${file} 
125      fi
126  fi
127
128  file=`ils ${i} 2>&1 | $GREP -i "dataRAw_.*\.ppf"`
129  file=`$ECHO $file`
130  if [ "<${file}>" != "<>" ]; then
131#      if [ ! -e ${file}  ]; then
132          iget -f -v ${i}/${file} 
133#      fi
134  fi
135
136
137 
138done
139
140exit 0
Note: See TracBrowser for help on using the repository browser.