source: BAORadio/AmasNancay/v2/transdate.sh@ 633

Last change on this file since 633 was 516, checked in by campagne, 14 years ago

change the tmppubicpath (jec)

File size: 1.7 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 touch ${tmppublicpath}/transdate.finished
36 exit 1
37fi
38cd ${iojobpath}
39
40if [ ! $# = 1 ]; then
41 $ECHO "FATAL (${scriptName}) usage: ./transdate.sh <scaXYZ.sum>"
42 touch ${tmppublicpath}/transdate.finished
43 exit 0
44fi
45
46#inputs x-chexk sca file
47inScaFile=$1
48if [ ! -e $inScaFile ]; then
49 $ECHO "FATAL (${scriptName}): $inScaFile not found"
50 touch ${tmppublicpath}/transdate.finished
51 exit 1
52fi
53
54$AWK -v datesys=$DATE '
55BEGIN {
56 FS=",";
57}
58
59{
60 cycle=$1;
61 for (i=2; i<=NF; i++) {
62 cmd=sprintf("%s +%%F -d \"%s\" ",datesys,$i);
63 (cmd | getline day);
64 close(cmd);
65 cmd=sprintf("%s +%%s -d \"%s\" ",datesys,day);
66 (cmd | getline s0);
67 close(cmd);
68 cmd=sprintf("%s +%%s -d \"%s\" ",datesys,$i);
69 (cmd | getline s1);
70 close(cmd);
71 $i = s1 - s0;
72 }
73 print $0;
74}
75
76' $inScaFile >> $inScaFile.trans
77
78touch ${tmppublicpath}/transdate.finished
79exit 0
Note: See TracBrowser for help on using the repository browser.