Jpp  18.0.0-rc.3
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
putFile.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 #
3 # \author mdejong
4 #
5 script=${0##*/}
6 
7 source ${0%${script}}ulib.sh
8 
9 set_variable: DEBUG ARCHIVE_DEBUG 2
11 
12 if do_usage $*; then
13  usage "$script <input file> <path> <detector identifier> <minimal run> <maximal run> <type> <version>"\
14  "\nUtility script to store file in archive."
15 fi
16 
17 case $# in
20  let ID=" $argv[3]";
21  let MINRUN=" $argv[4]";
22  let MAXRUN=" $argv[5]";
23  set_variable TYPE $argv[6];
25  *) fatal "Wrong number of arguments."
26 esac
27 
28 if [[ ! -d $DIR ]]; then
29  fatal "Invalid path $argv[2]"
30 fi
31 
32 if [[ ! -f $INPUT_FILE ]]; then
33  fatal "File $INPUT_FILE does not exist."
34 fi
35 
36 if (( $ID == 0 )); then
37  fatal "Invalid detector identifier $argv[3]"
38 fi
39 
40 if (( $MINRUN == 0 )); then
41  fatal "Invalid minimal run $argv[4]"
42 fi
43 
44 if (( $MAXRUN == 0 )); then
45  fatal "Invalid minimal run $argv[5]"
46 fi
47 
48 if (( $MINRUN > $MAXRUN )); then
49  fatal "Invalid minimal / maximal run $argv[4] / $argv[5]"
50 fi
51 
52 if [[ $VERSION == *[^[:alnum:_-]]* ]]; then
53  fatal "Invalid version $argv[7] (special characters not allowed)"
54 fi
55 
56 setopt extendedglob
57 
58 typeset -Z8 ID
59 typeset -Z8 MINRUN
60 typeset -Z8 MAXRUN
61 
62 let COUNTER="0"
63 
64 if [[ -d $DIR/$ID/$TYPE ]]; then
65 
66  typeset -T BUFFER ARRAY /
67 
68  (ls -1 $DIR/$ID/$TYPE/_*/*/*/*) 2> /dev/null | while read BUFFER; do
69 
70  set_variable A_ID ${ARRAY[-6]}
71  set_variable A_TYPE ${ARRAY[-5]}
72  set_variable A_VERSION ${ARRAY[-4]#_}
73  let A_MINRUN=" ${ARRAY[-3]}"
74  let A_MAXRUN=" ${ARRAY[-2]}"
75  set_variable A_FILENAME ${ARRAY[-1]}
76 
77  let A_COUNTER="${A_FILENAME:r}"
78 
79  if (( $MINRUN <= $A_MAXRUN && $MAXRUN >= $A_MINRUN )); then
80  if (( $A_COUNTER > $COUNTER )); then
81  let COUNTER="$A_COUNTER"
82  fi
83  fi
84  done
85 fi
86 
87 let COUNTER="$COUNTER + 1"
88 
89 set_variable OUTPUT_FILE $DIR/$ID/$TYPE/_${VERSION}/$MINRUN/$MAXRUN/${COUNTER}.${INPUT_FILE:e}
90 
91 mkdir -p ${OUTPUT_FILE:h}
92 
93 if (( $? != 0 )); then
94  fatal "Path ${OUTPUT_FILE:h} not created."
95 fi
96 
97 cp -p $INPUT_FILE $OUTPUT_FILE
98 
99 if (( $? == 0 )); then
100  notice "Stored $INPUT_FILE to archive:$OUTPUT_FILE"
101 else
102  fatal "File $INPUT_FILE not stored in archive."
103 fi
104 
then usage $script< detector identifier >< startdate\"YYYY-MM-DDHH:MM:SS\"><finaldate\"YYYY-MM-DDHH:MM:SS\"><QA/QCfile> fi case set_variable QAQC_TXT $argv[4]
Definition: JDataMonitor.sh:24
esac done BUFFER
Definition: JMakePDF.sh:77
o $QUALITY_ROOT d $DEBUG!CHECK_EXIT_CODE JPlot1D f
Definition: JDataQuality.sh:76
then fatal Wrong number of arguments fi DIR
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR &dev null set_variable
Definition: JAcoustics.sh:21
do set_variable OUTPUT_DIRECTORY $WORKDIR T
then fatal Invalid run $argv[3] fi setopt extendedglob typeset Z8 ID let COUNTER
Definition: getFile.sh:44
#define VERSION
Definition: elog-version.h:27
* usage
then JFileTuna f $INPUT_FILE
Definition: file-Tuna.sh:66
set_variable INPUT_FILE
then ls $DIR $ID
Definition: getArchive.sh:85
then JMuonMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
Definition: JMuonPath.sh:47
then eval ls $DIR $ID $TYPE _
Definition: getArchive.sh:104
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
let MINRUN
Definition: putFile.sh:21
script
Definition: JAcoustics.sh:2
let MAXRUN
Definition: putFile.sh:22
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62