#!/bin/bash -e #Declare the Associative array 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" echo $postgres_con ( echo "*****************************" echo "**Latest File Update Status**" echo "*****************************" echo " " psql $postgres_con -c "select run_schedule_id, file_syspk, file_mnemonic, file_name, end_status as status, end_time from fw_core.fw_jobctl_file_runschedule where run_schedule_id in (select max(run_schedule_id) from fw_core.fw_jobctl_file_runschedule) order by run_schedule_id, file_syspk, end_status desc;" echo " " echo "**********************************" echo "**Error Files********************" echo "**********************************" echo " " psql $postgres_con -c "select A.run_schedule_id, A.file_syspk, A.file_mnemonic, A.file_name, B.sheet_id, B.sheet_name, A.end_status, A.end_time from fw_core.fw_jobctl_file_runschedule a, fw_core.fw_jobctl_file_sheet_runschedule b where a.run_schedule_id = (select max(run_schedule_id) from fw_core.fw_jobctl_file_runschedule) and a.file_syspk = b.file_syspk and (b.file_sheet_mnemonic != '' or b.file_sheet_mnemonic is not null) and b.end_status='error' order by A.run_schedule_id, b.file_syspk, b.sheet_id desc limit 10" ) | mail -s 'FIles Load Status' muin.shariff@compegence.com abdur.rahman@compegence.com dheepa.k@compegence.com jagadish.puvvada@compegence.com -a "From: noreply@forewarn.com"