#!/usr/bin/ksh # # This script writes information from lists of EPO jpg files to the EPOMAG database. # It is intended to be used when for some reason the automatic daily write of file names to the database has failed. # # Written because for some reason the epo_magfile_append script did not write info to # the EPOMAG database on juneau between Oct 2010 and Sep 2011 (when the problem was fixed) # Lists of files should be generated first using update_epomag_table.ksh # # lphilpott 7-oct-2011 # Broadly copied from epo_magfile_append.ksh # ## Set the environment variables # if [[ -z $THMSOC ]] then THMSOC=/disks/socware/thmsoc_dp_current export THMSOC fi . $THMSOC/src/config/thmsoc_epo.config cd $EPO_HOME n=0 #school=${SCHOOL[$n]} school=UKIA basepath=/home/thmsoc/lphilpotts_stuff/epomagupdate #while [[ -n $school ]] #do while read ts123line do xyzmag_file_name=$ts123line # get MMDDYYYY_HHMMSS date_string=$(echo $xyzmag_file_name | awk -F_ '{print $3 "_" $4}') mysql_table=${school}_TS123 mysql_date=$(echo $date_string | awk -F_ '{print substr($1,5,4) "-" substr($1,1,2) "-" substr($1,3,2)}') mysql_time=$(echo $date_string | awk -F_ '{print substr($2,1,2) ":" substr($2,3,2) ":" substr($2,5,2)}') /usr/local/bin/php $THMSOC/src/php/epo_cmdline_input.php $mysql_table $mysql_date $mysql_time $xyzmag_file_name #just checking #echo "TABLE: $mysql_table" #echo "DATE: $mysql_date" #echo "TIME: $mysql_time" #echo "FILENAME: $xyzmag_file_name" done < $basepath/${school}_ts123_files while read tsbdhline do bdhmag_file_name=$tsbdhline # get MMDDYYYY_HHMMSS date_string=$(echo $bdhmag_file_name | awk -F_ '{print $3 "_" $4}') mysql_table=${school}_TSBDH mysql_date=$(echo $date_string | awk -F_ '{print substr($1,5,4) "-" substr($1,1,2) "-" substr($1,3,2)}') mysql_time=$(echo $date_string | awk -F_ '{print substr($2,1,2) ":" substr($2,3,2) ":" substr($2,5,2)}') /usr/local/bin/php $THMSOC/src/php/epo_cmdline_input.php $mysql_table $mysql_date $mysql_time $bdhmag_file_name done < $basepath/${school}_tsbdh_files while read ds123line do xyzmag_file_name=$ds123line # get MMDDYYYY_HHMMSS date_string=$(echo $xyzmag_file_name | awk -F_ '{print $3 "_" $4}') mysql_table=${school}_DS123 mysql_date=$(echo $date_string | awk -F_ '{print substr($1,5,4) "-" substr($1,1,2) "-" substr($1,3,2)}') mysql_time=$(echo $date_string | awk -F_ '{print substr($2,1,2) ":" substr($2,3,2) ":" substr($2,5,2)}') /usr/local/bin/php $THMSOC/src/php/epo_cmdline_input.php $mysql_table $mysql_date $mysql_time $xyzmag_file_name done < $basepath/${school}_ds123_files while read dsbdhline do bdhmag_file_name=$dsbdhline # get MMDDYYYY_HHMMSS date_string=$(echo $bdhmag_file_name | awk -F_ '{print $3 "_" $4}') mysql_table=${school}_DSBDH mysql_date=$(echo $date_string | awk -F_ '{print substr($1,5,4) "-" substr($1,1,2) "-" substr($1,3,2)}') mysql_time=$(echo $date_string | awk -F_ '{print substr($2,1,2) ":" substr($2,3,2) ":" substr($2,5,2)}') /usr/local/bin/php $THMSOC/src/php/epo_cmdline_input.php $mysql_table $mysql_date $mysql_time $bdhmag_file_name done < $basepath/${school}_dsbdh_files while read tspectraline do tspectra_file_name=$tspectraline # get MMDDYYYY_HHMMSS date_string=$(echo $tspectra_file_name | awk -F_ '{print $3 "_" $4}') mysql_table=${school}_TSpectra mysql_date=$(echo $date_string | awk -F_ '{print substr($1,5,4) "-" substr($1,1,2) "-" substr($1,3,2)}') mysql_time=$(echo $date_string | awk -F_ '{print substr($2,1,2) ":" substr($2,3,2) ":" substr($2,5,2)}') /usr/local/bin/php $THMSOC/src/php/epo_cmdline_input.php $mysql_table $mysql_date $mysql_time $tspectra_file_name done < $basepath/${school}_tspectra_files while read dspectraline do dspectra_file_name=$dspectraline # get MMDDYYYY_HHMMSS date_string=$(echo $dspectra_file_name | awk -F_ '{print $3 "_" $4}') mysql_table=${school}_DSpectra mysql_date=$(echo $date_string | awk -F_ '{print substr($1,5,4) "-" substr($1,1,2) "-" substr($1,3,2)}') mysql_time=$(echo $date_string | awk -F_ '{print substr($2,1,2) ":" substr($2,3,2) ":" substr($2,5,2)}') /usr/local/bin/php $THMSOC/src/php/epo_cmdline_input.php $mysql_table $mysql_date $mysql_time $dspectra_file_name done < $basepath/${school}_dspectra_files # n=$(( n + 1 )) # school=${SCHOOL[$n]} #done exit 0