[507] | 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 |
---|
[516] | 24 | tmppublicpath=${TMPPUBLICPATH} |
---|
[507] | 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 | touch ${tmppublicpath}/transdate.finished |
---|
| 36 | exit 1 |
---|
| 37 | fi |
---|
| 38 | cd ${iojobpath} |
---|
| 39 | |
---|
| 40 | if [ ! $# = 1 ]; then |
---|
| 41 | $ECHO "FATAL (${scriptName}) usage: ./transdate.sh <scaXYZ.sum>" |
---|
| 42 | touch ${tmppublicpath}/transdate.finished |
---|
| 43 | exit 0 |
---|
| 44 | fi |
---|
| 45 | |
---|
| 46 | #inputs x-chexk sca file |
---|
| 47 | inScaFile=$1 |
---|
| 48 | if [ ! -e $inScaFile ]; then |
---|
| 49 | $ECHO "FATAL (${scriptName}): $inScaFile not found" |
---|
| 50 | touch ${tmppublicpath}/transdate.finished |
---|
| 51 | exit 1 |
---|
| 52 | fi |
---|
| 53 | |
---|
| 54 | $AWK -v datesys=$DATE ' |
---|
| 55 | BEGIN { |
---|
| 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 | |
---|
| 78 | touch ${tmppublicpath}/transdate.finished |
---|
| 79 | exit 0 |
---|