#!/bin/csh -f
if ("$2" == "") then
        echo "usage: updateSCRuseLog <snapshot> <mode>"
        exit
        endif
set ulog = u$1
set mode = $2
set dtStamp = `date +%y.%m.%d.%H:%M:%S`
set tmproot = "/tmp/"${user}${dtStamp}
mecho "SDDS1\n&column name=YearUsed type=long &end\n" >! $tmproot
mecho "&column name=MonthUsed type=long &end\n" >> $tmproot
mecho "&column name=DayUsed type=long &end\n" >> $tmproot
mecho "&column name=JulianDayUsed type=long &end\n" >> $tmproot
mecho "&column name=Time type=string &end\n" >> $tmproot
mecho "&column name=Mode type=string &end\n" >> $tmproot
mecho "&data mode=ascii no_row_counts=1 &end\n" >> $tmproot
mecho `date +%y` " " `date +%m` " " `date +%d` " " `date +%j` " " `date +%H:%M:%S` " $mode \n" >> $tmproot

cd /home/helios/oagData/SCR/snapshots
if (-e $ulog) then
        cp $ulog $tmproot-1
        \rm -f $ulog
        sddscombine $tmproot $tmproot-1 $ulog -overwrite -merge
        chmod a+w $ulog
else
        cp $tmproot $ulog
        chmod a+w $ulog
        endif

\rm ${tmproot}*
        
