#!/bin/bash -e #/**************************************************************** #****** ForeWarn Licensing and / or usage Terms and Conditions ***** #ForeWarn. The NextGen Insights Solution Platform #Copyright © 2021 COMPEGENCE. All Rights Reserved #ForeWarn is a product of COMPEGENCE. #To be used only with a valid license from COMPEGENCE #www.compegence.com info@compegence.com #****************************************************************/ #HOME="/home/compegence/customer" #Directories fileDir="/data/customer/MMT" homeDir=$HOME/customer/MMT configDir=$homeDir/conf input_file=$configDir/etl-config.txt declare -A credentials while IFS="=" read -r key value; do credentials[$key]=$value done < <( sed -e '/^\s*$/ d' -e '/^#/ d' $input_file ) user=${credentials[user]} password=${credentials[password]} host=${credentials[host]} db=${credentials[db]} protocol=${credentials[protocol]} server=${credentials[server]} postgres_con="psql -A -t postgresql://$user:$password@$host/$db" filesyspks=`$postgres_con -q -c "select file_syspk from fw_core.fw_jobctl_file_runschedule where latest_runschedule_flag='1' /*and end_status_note='TRX_completed'*/;"` for filesyspk in ${filesyspks} do IFS="|" read name endstatus endnote <<<`$postgres_con -c "select file_name,end_status,end_status_note from fw_core.fw_jobctl_file_runschedule where file_syspk=$filesyspk"` filename=$(echo $name | sed 's/[[:space:]]/\\ /g') if [ $endstatus == "success" -a $endnote == 'ODS_completed' ] then echo " moving file:$filename to processed folder" move=$(echo "mv $fileDir/files/landing/$filename $fileDir/files/processed/$filename") eval $move else echo "moving file: $filename to error_file folder " move=$(echo "mv $fileDir/files/landing/$filename $fileDir/files/error_file/$filename") eval $move fi $postgres_con -q -c "update fw_core.fw_jobctl_runschedule_jobstep set end_status_note ='file_movement_completed', end_status='success',end_time = now() where job_script_type = 'shell_script' and latest_runschedule_flag='1' and job_name= 'file_cleanup'" echo -e ' ' done #$postgres_con -c "insert into fw_core.track_jobstep select *,'move_check' from fw_core.fw_jobctl_runschedule_jobstep;" #$postgres_con -c "insert into fw_core.track_file select *,'move_check' from fw_core.fw_jobctl_file_runschedule;" #$postgres_con -c "insert into fw_core.track_file_sheet select *,'move_check' from fw_core.fw_jobctl_file_sheet_runschedule;"