source: BAORadio/AmasNancay/trunk/transdate.sh @ 563

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

move to trunk the previous HEAD (jec)

File size: 1.8 KB
Line 
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
5AWK=/bin/awk
6SED=/bin/sed
7GREP=/bin/grep
8WC=/usr/bin/wc
9RM=/bin/rm
10CAT=/bin/cat
11TOUCH=/bin/touch
12DATE=/bin/date
13ECHO=/bin/echo
14LS=/bin/ls
15MKDIR=/bin/mkdir
16DefaultIFS=$' \t\n'
17IFS=$DefaultIFS
18
19
20scriptName="`basename $0`"
21$ECHO "Processing script ${scriptName} at `date`"
22
23#temporary files to synchronize scripts
24tmppublicpath=${TMPPUBLICPATH}
25$LS -l ${tmppublicpath} > /dev/null
26
27#Path where the job will do temporary IO
28if [ ${ENVIRONMENT} = "INTERACTIVE" ]; then
29    iojobpath="/sps/baoradio/AmasNancay/JEC"
30    $MKDIR -p $iojobpath
31elif [ ${ENVIRONMENT} = "BATCH" ] ; then
32     iojobpath=${TMPBATCH}
33else
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
38fi
39cd ${iojobpath}
40
41if [ ! $# = 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
46fi
47
48#inputs x-chexk sca file
49inScaFile=$1
50if [ ! -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
55fi
56
57$AWK -v datesys=$DATE '
58BEGIN {
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
83exit 0
Note: See TracBrowser for help on using the repository browser.