Jpp  debug
the software that should make you happy
datalogs.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 script=${0##*/}
3 
4 if [ -z $JPP_DIR ]; then
5  echo "Variable JPP_DIR undefined."
6  exit
7 fi
8 
9 source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
10 
11 set_variable: DEBUG DATABASE_DEBUG 2
12 set_variable: WORKDIR DATABASE_WORKDIR `pwd`
13 
14 if do_usage $*; then
15  usage "$script <detector identifier> <run>[-<run>] [source [parameter]]"
16 fi
17 
18 case $# in
19  4) set_variable PARAMETER $4;&
20  3) set_variable SOURCE $3;&
21  2) set_variable RUNS $2;
22  set_variable DETID $1;;
23  *) fatal "Invalid number of arguments."
24 esac
25 
26 set_variable DETID `getDetector -D $DETID -O string`
27 set_variable FILENAME $WORKDIR/${DETID}_${RUNS}${SOURCE+.}${SOURCE}.log
28 
29 SELECTOR=(
30  "detid=$DETID"
31  "minrun=${RUNS%%-*}"
32  "maxrun=${RUNS##*-}")
33 
34 if [[ -n "$SOURCE" ]]; then; SELECTOR+="source_name=$SOURCE"; fi
35 if [[ -n "$PARAMETER" ]]; then; SELECTOR+="parameter_name=$PARAMETER"; fi
36 
37 if [[ ! -f ${FILENAME}.gz ]]; then
38 
39  wget \
40  --load-cookies=$HOME/.km3netdb_cookie \
41  --secure-protocol=TLSv1_2 \
42  "https://km3netdbweb.in2p3.fr/streamds/datalogstrings.txt?${(j:&:)SELECTOR}" \
43  -O ${FILENAME}
44 
45  echo
46 
47  if (( $? == 0 )) && [[ `head ${FILENAME}` != "ERROR: "* ]]; then
48  gzip -v ${FILENAME}
49  else
50  fatal "wget error"
51  fi
52 fi