#!/usr/bin/ksh # # lrv_back_files.ksh # # Author: Lydia Philpott (lphilpott@igpp.ucla.edu) # # Draft script to copy back files from LRV to the appropriate # locations and write info to database # This script has not been tested! # ## Set environment variables # if [[ -z $THMSOC ]] then THMSOC=/disks/socware/thmsoc_dp_current export THMSOC fi . $THMSOC/src/config/soc_it_to_me.config # . $THMSOC/src/config/wget_lrv_gmag.config LOCALWEBMIRROR=/home/thmsoc/lphilpotts_stuff/lrv_wget_test GMAGWORKDIR=/home/thmsoc/lphilpotts_stuff/lrv_wget_test/workdir/lrv2do site=lrv wgetTime=$(date '+%Y-%m-%d %T') #EDIT the file location below (nb. no spaces before or after '=') #Note that if the files for each year in are in separate files you may want to run this separately for each folder filelocation=/home/thmsoc/lphilpotts_stuff/lrv_wget_test #Obtain a list of the files to be moved # (it is a one, not an l ie create a single column list of files) files=$(ls -1 $filelocation/*.sec.gz) for f in $files do # GAIA2 prints the fullpath -if script doesn't work this is a good place to start looking for bugs fileName=$(basename $f) fileName=${fileName%*\'} # Parse date information from filename year=$(echo $fileName |awk '{print "20" substr($1,1,2)}') echo $year doy=$(echo $fileName |awk '{print substr($1,3,3)}') date=$(doy2date $year $doy) mon=$(echo $date |awk -F/ '{print $2}') day=$(echo $date |awk -F/ '{print $3}') fileTime=$(echo $year $mon $day | awk '{printf("%s-%02s-%02s 00:00:00", $1,$2,$3)}') fileSize=$(ls -l ${filelocation}/${fileName} |awk '{print $5}') # copy the file to the mirror directory (http://themis.ssl.berkeley.edu/data/themis/thg/mirrors/mag/lrv_ascii/lrv/) # LOCALWEBMIRROR is set in the wget_lrv_gmag.config file above cp ${filelocation}/${fileName} ${LOCALWEBMIRROR}/${site}/${year}/${fileName} # Update database with stats # If you are testing the script initially, comment out the writing to the database # and uncomment the 'echo' line below to see the parameters passed to the php script #${PHP_SCRIPTS}/wget_lrv_gmag.php $fileName $wgetTime $fileTime $fileSize echo "$fileName $wgetTime $fileTime $fileSize" # Create a file used for CDF processing cp ${LOCALWEBMIRROR}/${site}/${year}/${fileName} ${GMAGWORKDIR}/$fileName done ## Cleanup # exit 0