1 | #!/bin/sh
|
---|
2 | # transforme les dates en nombre de seconde depuis minuit
|
---|
3 | # pour reecrire les start/stop des differentes phases du fichier sca
|
---|
4 |
|
---|
5 | AWK=/bin/awk
|
---|
6 | SED=/bin/sed
|
---|
7 | GREP=/bin/grep
|
---|
8 | WC=/usr/bin/wc
|
---|
9 | RM=/bin/rm
|
---|
10 | CAT=/bin/cat
|
---|
11 | TOUCH=/bin/touch
|
---|
12 | DATE=/bin/date
|
---|
13 | ECHO=/bin/echo
|
---|
14 | LS=/bin/ls
|
---|
15 | MKDIR=/bin/mkdir
|
---|
16 | DefaultIFS=$' \t\n'
|
---|
17 | IFS=$DefaultIFS
|
---|
18 |
|
---|
19 |
|
---|
20 | scriptName="`basename $0`"
|
---|
21 | $ECHO "Processing script ${scriptName} at `date`"
|
---|
22 |
|
---|
23 | #temporary files to synchronize scripts
|
---|
24 | tmppublicpath=${TMPPUBLICPATH}
|
---|
25 | $LS -l ${tmppublicpath} > /dev/null
|
---|
26 |
|
---|
27 | #Path where the job will do temporary IO
|
---|
28 | if [ ${ENVIRONMENT} = "INTERACTIVE" ]; then
|
---|
29 | iojobpath="/sps/baoradio/AmasNancay/JEC"
|
---|
30 | $MKDIR -p $iojobpath
|
---|
31 | elif [ ${ENVIRONMENT} = "BATCH" ] ; then
|
---|
32 | iojobpath=${TMPBATCH}
|
---|
33 | else
|
---|
34 | $ECHO "FATAL (${scriptName}): environment is ${ENVIRONMENT} not allowed"
|
---|
35 | #JEC 29/9/11 avoid finished stuff
|
---|
36 | # touch ${tmppublicpath}/transdate.finished
|
---|
37 | exit 1
|
---|
38 | fi
|
---|
39 | cd ${iojobpath}
|
---|
40 |
|
---|
41 | if [ ! $# = 1 ]; then
|
---|
42 | $ECHO "FATAL (${scriptName}) usage: ./transdate.sh <scaXYZ.sum>"
|
---|
43 | #JEC 29/9/11 avoid finished stuff
|
---|
44 | # touch ${tmppublicpath}/transdate.finished
|
---|
45 | exit 0
|
---|
46 | fi
|
---|
47 |
|
---|
48 | #inputs x-chexk sca file
|
---|
49 | inScaFile=$1
|
---|
50 | if [ ! -e $inScaFile ]; then
|
---|
51 | $ECHO "FATAL (${scriptName}): $inScaFile not found"
|
---|
52 | #JEC 29/9/11 avoid finished stuff
|
---|
53 | # touch ${tmppublicpath}/transdate.finished
|
---|
54 | exit 1
|
---|
55 | fi
|
---|
56 |
|
---|
57 | $AWK -v datesys=$DATE '
|
---|
58 | BEGIN {
|
---|
59 | FS=",";
|
---|
60 | }
|
---|
61 |
|
---|
62 | {
|
---|
63 | cycle=$1;
|
---|
64 | for (i=2; i<=NF; i++) {
|
---|
65 | cmd=sprintf("%s +%%F -d \"%s\" ",datesys,$i);
|
---|
66 | (cmd | getline day);
|
---|
67 | close(cmd);
|
---|
68 | cmd=sprintf("%s +%%s -d \"%s\" ",datesys,day);
|
---|
69 | (cmd | getline s0);
|
---|
70 | close(cmd);
|
---|
71 | cmd=sprintf("%s +%%s -d \"%s\" ",datesys,$i);
|
---|
72 | (cmd | getline s1);
|
---|
73 | close(cmd);
|
---|
74 | $i = s1 - s0;
|
---|
75 | }
|
---|
76 | print $0;
|
---|
77 | }
|
---|
78 |
|
---|
79 | ' $inScaFile >> $inScaFile.trans
|
---|
80 |
|
---|
81 | #JEC 29/9/11 avoid finished stuff
|
---|
82 | #touch ${tmppublicpath}/transdate.finished
|
---|
83 | exit 0
|
---|