#!/usr/bin/ksh # # update_usgs_database.ksh # # Author: Lydia Philpott (lphilpott@igpp.ucla.edu) # # This script is intended to generate a list of USGS ascii files and write them # to the database - written to add the backfiles to the database as they were downloaded # manually. NOTE the filenames of the raw/sec files are a different format to the IAGA2002 #files so this script will not run as is for IAGA2002 files # ## 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_usgs_gmag.config # ## Handle input arguments # site=brw year=2007 #month=${3} # ## Set logfiles # processTime=$(date -u '+%y-%m-%d %T') for month in 01 02 03 04 05 06 07 08 09 10 11 12 do filedir=${LOCALWEBMIRROR}/${site}/${year}/${month} files=$(ls -1 $filedir) echo "$filedir" echo "$files" for f in $files do fileName=$f fullfilepath=${filedir}/${f} fileSize=$(ls -l ${fullfilepath} | awk '{print $5}') # Parse date information from filename year=$(echo $fileName |awk -F_ '{print substr($1,4,4)}') doy=$(echo $fileName |awk -F_ '{print substr($1,8,3)}') date=$(/disks/socware/thmsoc_dp_current/src/ksh/doy2date $year $doy) mon=$(echo $date | awk -F/ '{printf("%02d",$2)}') day=$(echo $date | awk -F/ '{printf("%02d",$3)}') fileTime="${year}-${mon}-${day} 00:00:00" # Update database with stats echo "$fileName $processTime $fileTime $fileSize" ${PHP_SCRIPTS}/wget_usgs_gmag.php $fileName $processTime $fileTime $fileSize done # ## Cleanup # done exit 0