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

Last change on this file since 590 was 579, checked in by torrento, 13 years ago

version adaptee a grid engin (ana)

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