Sunteți pe pagina 1din 23

#!

/usr/bin/ksh
#set -ex
# Author:
Suri B Kopanna
#
# Project:
Insourcing
#
# Script Name:
Issuer_Profile_Check_Counts.sh
#
# Purpose:
To Read the Issprof_files.txt and get the #
#
src file ,check counts done for EmbTrust #
#
Issuer Profile for structured and unstructured
#
#
file(s).
#
# Software Used:
UNIX
#
#
#
#
#
#
#
####################################################################
#
Modification Log
#
####################################################################
#
Date
Init.
Description
#
####################################################################
# 10/10/2014 Version 1.0
#
####################################################################
. /download/INFA/DefaultIT/Dharmas/Scripts/bin/.dharmas_unix_variables
user_path=`pwd`
MAIL_LIST='doc_data_prod_support@restricted.chase.com'
user_path=`pwd`
if [[ `echo $user_path | grep -i -c '.*SwornDocs_IST.*'` -eq 0 ]];then
user_env='SwornDocs'
else
user_env='SwornDocs_IST'
fi
function log {
str="$1"
echo " $(date +"%Y%m%d%H%M%S") - $str " >> $log_file 2>&1
}
function dup_run_chk {
if [[ -f "$1" ]];then
rm -rf "$1"
log " removed the $1."
else
log " Error: Unable to remove the $1."
msg_str="Error: Unable to remove the $1"
(echo "${msg_str}";uuencode $log_file $log_file;) | mailx -s "ALERT:$msg_str" $M
AIL_LIST
fi
return 0
}
curr_zip_type="$1"
##bs_mlrun_fl="/tmp/dts_to_il"
bs_mlrun_fl="/docdata/DefaultIT/DocMgmt/${user_env}/Temp/dts_to_il"
case $curr_zip_type in
'LPSD')
## echo "In Option = $curr_env"
log " LPSD "
srch_file="lps_*.zip"

mod_dir='LPSD'
src_sub_dir="${user_env}/${mod_dir}/SrcFiles/"
fl_extn_val="txt"
outb_prfx="LPSD_to_DOCDATA"
mlrun_fl="${bs_mlrun_fl}_${curr_zip_type}_tcop_$(date +'%Y%m%d%H%M%S').fl"
src_sub_dir="${user_env}/${mod_dir}/SrcFiles/"
src_zip_dir="${user_env}/${mod_dir}/InboundFiles/"
src_xml_dir="${user_env}/${mod_dir}/SrcFiles/"
fl_extn_val="xml"
mlrun_fl="${bs_mlrun_fl}_${curr_zip_type}_tcop_$(date +'%Y%m%d%H%M%S').fl"
rezip_fl_nm=''
rezip_fl_size=''
;;
*)
log "No Valid Option! Exiting.."
exit 0
;;
esac
###################
# set the search str for the files in case the above origs not exist.
######################
brow_srch_str='BorrowerInfo_'
form_srch_str='FormInfo_[0-9][0-9]'
loan_srch_str='LoanInfo_'
proc_srch_str='ProcInfo_'
proc_meta_srch_str='ProcMetaInfo_'
ref_info_srch_str='RefInfo_'
forminfo_drsmetainfo_srch_str='FormInfo_DRSMe*_'
###################
# dummy up the files in case the above origs not exist.
######################
brow_tch_fl="${brow_srch_str}$(date +'%m%d%Y%H%M%S').txt"
form_tch_fl="${form_srch_str}$(date +'%m%d%Y%H%M%S').txt"
loan_tch_fl="${loan_srch_str}$(date +'%m%d%Y%H%M%S').txt"
proc_tch_fl="${proc_srch_str}$(date +'%m%d%Y%H%M%S').txt"
proc_meta_tch_fl="${proc_meta_srch_str}$(date +'%m%d%Y%H%M%S').txt"
ref_tch_fl="${ref_info_srch_str}$(date +'%m%d%Y%H%M%S').txt"
drsmeta_tch_fl="${forminfo_drsmetainfo_srch_str}$(date +'%m%d%Y%H%M%S').txt"
inb_dir="/docdata/DefaultIT/DocMgmt/${user_env}/${mod_dir}/InboundFiles/"
#src_file="/docdata/DefaultIT/DocMgmt/${user_env}/SrcFiles/$src_file_rw"
src_base_dir="/docdata/DefaultIT/DocMgmt/"
##src_sub_dir="${user_env}/${mod_dir}/SrcFiles/"
src_dir="${src_base_dir}${src_sub_dir}"
zip_dir="${src_base_dir}${src_zip_dir}"
xml_dir="${src_base_dir}${src_xml_dir}"
##dtl_fl_dir="${src_base_dir}${src_xml_dir}"
infa_junct_dir="/docdata/DefaultIT/DocMgmt/${user_env}/${mod_dir}/SrcFiles/"
lpsd_inb_dir="/docdata/DefaultIT/DocMgmt/${user_env}/${mod_dir}/InboundFiles/"
lpsd_outb_dir="/docdata/DefaultIT/DocMgmt/${user_env}/${mod_dir}/SrcFiles/"
log_file=/docdata/DefaultIT/DocMgmt/${user_env}/Scripts/logs/lpsd_to_ddata_daily
_$(date +"%Y%m%d%H%M%S").log
arch_dir=/docdata/DefaultIT/DocMgmt/${user_env}/Archive/
file_prm=775
####################################################################
# Has the list he files from Inbound

####################################################################
##inbound_daily_file="/docdata/DefaultIT/DocMgmt/${user_env}/${mod_dir}/SrcFiles
/inbound_daily_file_$(date +'%Y%m%d%H%M%S').txt"
inbound_daily_file="/docdata/DefaultIT/DocMgmt/${user_env}/${mod_dir}/SrcFiles/i
nbound_daily_${curr_zip_type}_$$_file_$(date +'%Y%m%d%H%M%S').lst"
inbound_daily_orig_file="/docdata/DefaultIT/DocMgmt/${user_env}/${mod_dir}/SrcFi
les/inbound_daily_orig_${curr_zip_type}_$$_file_$(date +'%Y%m%d%H%M%S').lst"
##infa_lst_file="${src_dir}/infa_dts_to_ils_daily_load_$(date +'%Y%m%d%H%M%S').l
st"
infa_lst_file="${src_dir}sd_${curr_zip_type}_$$_infa_dts_to_ils_daily_load_$(dat
e +'%Y%m%d%H%M%S').lst"
##all_mov_file="${src_dir}/dts_to_ils_all_mov_fl_$(date +'%Y%m%d%H%M%S').lst"
all_mov_file="${src_dir}sd_${curr_zip_type}_$$_dts_to_ils_all_mov_fl_$(date +'%Y
%m%d%H%M%S').lst"
cpy_flag=0
succss=0
failed=1
files_exist=0
unzp_flag=0
files_exist=0
data_fl_exist=0
byt_chk=0
fl_extn_val="txt"
mfl_name=''
mfl_count=''
mfl_src_loc=''
mfl_upld_tmstp=''
mfl_dwnld_tmstp=''
mfl_tgt_loc=''
mfl_size=''
mfl_srce_rd_tmstp=''
rezip_fl_nm=''
rezip_fl_size=''
mfl_status=''
mfl_err_status=''
dfl_name=''
dfl_count=''
dfl_src_loc=''
dfl_upld_tmstp=''
dfl_dwnld_tmstp=''
dfl_tgt_size=''
dfl_size=''
dfl_srce_rd_tmstp=''
dfl_status=''
dtl_err_status=''
touch
chmod
touch
chmod
touch
chmod
touch
chmod
touch
chmod

${infa_lst_file}
$file_prm ${infa_lst_file}
${all_mov_file}
$file_prm ${all_mov_file}
${inbound_daily_file}
$file_prm ${inbound_daily_file}
${log_file}
$file_prm ${log_file}
${inbound_daily_orig_file}
$file_prm ${inbound_daily_orig_file}

log "inb_dir = $inb_dir."


log "Log_File = $log_file."
echo " "
if [[ -f "${mlrun_fl}" ]];then
log " Already a job is executing for the same category ${curr_zip_type}, exit
ing..."
exit 0
else
touch ${mlrun_fl}
chmod $file_prm ${mlrun_fl}
log " created the mlru file ${mlrun_fl}, moving forward "
####################################################################
# Get the files from Inbound
####################################################################
log " file(s) = ${infa_lst_file} "
to_del_fl=`echo "${infa_lst_file}" | awk -F'/' '{print $8;}' | cut -d'_' -f3`
if [[ ${to_del_fl} -ge 0 ]];then
log " Valid value,pruing the temp file(s) for ${to_del_fl} "
else
to_del_fl=$(date +'%Y%m%d%H%M%S')
log " pruing the temp file(s) for ${to_del_fl} "
fi
cd "${inb_dir}"
for zp_fl_nm in $( find . \( ! -name . -prune \) -type f -name "$srch_file" -ex
ec ls -lt {} \;| awk '{print $9;}' | sed -e 's/\.\///g' )
do
files_exist=1
if [[ ${curr_zip_type} != 'LPSD' ]];then
echo "${zp_fl_nm}" | sed -e 's/..*\///g' >> ${inbound_daily_file}
# alreadyif [[ ${curr_zip_type} != 'CC' ]];then
# alreadymv ${zp_fl_nm} ${src_dir}
#alreadyelif [[ ${curr_zip_type} = 'CC' ]];then
# already mv ${zp_fl_nm} ${unfold_zip_dir}
##alreadyelse
log " Movn ${zp_fl_nm} to ${src_dir} "
mv ${zp_fl_nm} ${src_dir}
else
##if already [[ `echo ${zp_fl_nm} | cut -d"." -f1 |grep -nc 'lps_..*5
[23]$'` -eq 1 ]];then
##rn_fl=`echo ${zp_fl_nm} | cut -d"." -f1`
##blss_zp_fl_nm="${rn_fl}_$(date +'%Y%m%d%H%M%S').zip"
## alreadyfi
##mv ${zp_fl_nm} ${blss_zp_fl_nm}
##log " moved the files to new name ${blss_zp_fl_nm} "
## echo "${blss_zp_fl_nm}" | sed -e 's/..*\///g' >> ${inbound_daily_f
ile}
echo "${zp_fl_nm}" | sed -e 's/..*\///g'

>> ${inbound_daily_orig_file

}
fi
done
#######
### Byte Chk
##############
Module="${curr_zip_type}"
FL_DROP_LOC="${inb_dir}"
bytcmp_list_file="${inbound_daily_orig_file}"
user_env="${user_env}"
mod_dir="${mod_dir}"
to_del_fl="${to_del_fl}"
log_file="${log_file}"
####script calling syntax sh -x intralinks_sftp_loop_fl.ksh TL Template_Library/
Inbound Template_Library##########
src_base_dir="/docdata/DefaultIT/DocMgmt/"
FILE_DIR="${src_base_dir}${user_env}/${mod_dir}/SrcFiles/"
echo "##########################################################################
##########" >> ${log_file}
echo "####################
Have All Files , Compare now
####################" >> ${log_file}
echo "##########################################################################
##########" >> ${log_file}
cd "${FL_DROP_LOC}"
try_cnt=0
#until false
while [[ $try_cnt -lt 10 ]];
do
echo "
">> ${log_file}
echo "
">> ${log_file}
echo "--------------------------------------------------------------------------" >> ${log_file}
echo "-------------------------------Loop $try_cnt of 10 -----------------------------" >> ${log_file}
echo "--------------------------------------------------------------------------" >> ${log_file}
##### ##########################################################
#############################################
############ checking current log with previous log and sftping
the files ##################################
##### ##########################################################
#############################################
try_cnt=`expr $try_cnt + 1`
previous_curr_log="${FILE_DIR}${Module}_${try_cnt}_LPSD_DTS_${t
o_del_fl}_prev_bytcmp_$(date +'%Y%m%d%H%M%S').tmp"
touch $previous_curr_log
chmod $file_prm $previous_curr_log
log " descr to $previous_curr_log "
cat ${bytcmp_list_file} | while read line ;do
ls -lt "$line" | awk '{print $5"|"$9;}' | sed -e 's/\.\///g' >
> $previous_curr_log
done
cat $previous_curr_log >> ${log_file}

#previous_log_count=`expr $try_cnt - 1`
sleep 30
##sleep 2

current_log="${FILE_DIR}${Module}_${try_cnt}_LPSD_DTS_${to_del_f
l}_curr_bytcmp_$(date +'%Y%m%d%H%M%S').tmp"
touch $current_log
chmod $file_prm $current_log
log " $line to $current_log "
cat ${bytcmp_list_file} | while read line ;do
ls -lt "$line" | awk '{print $5"|"$9;}' | sed -e 's/\.\///g' >
> $current_log
done
cat $current_log >> ${log_file}
done
##### ##########################################################################
#############################
############ checking current log with previous log and sftping the files #####
#############################
##### ##########################################################################
#############################
if [[ -s $previous_curr_log ]];then
if [[ -s $current_log ]];then
if [[ `diff $current_log $previous_curr_log | wc -l`
-eq 0 ]];then
log " bytes counts match "
cat $previous_curr_log >> "${log_file}"
cat $current_log >> "${log_file}"
ret_val=0;
#### renm files to date and tmstp
cd "${inb_dir}"
for zp_fl_nm in $( find . \( ! -name . prune \) -type f -name "$srch_file" -exec ls -lt {} \;| awk '{print $9;}' | se
d -e 's/\.\///g' )
do
files_exist=1
rn_fl=`echo ${zp_fl_nm} | cut -d
"." -f1`
blss_zp_fl_nm="${rn_fl}_$(date +
'%Y%m%d%H%M%S').zip"

mv ${zp_fl_nm} ${blss_zp_fl_nm}
##log " moved the files to new
name ${blss_zp_fl_nm} "
if [[ "$?" -eq 0 ]];then
echo "${blss_zp_fl_nm}" | sed
-e 's/..*\///g'

>> ${inbound_daily_file}

} to ${blss_zp_fl_nm} "

else
echo "Unable to ren ${zp_fl_nm
>> ${inbound_daily_file}
fi
done
#### fnsh renm files to date and tmstp
else
log " Error: bytes counts match "
cat $previous_curr_log >> "${log_file}"
cat $current_log >> "${log_file}"
ret_val=99;
fi

else
log " error: $current_log, has no data"
ret_val=90;
fi
else
log " error: $previous_curr_log, has no data"
ret_val=90;
fi

##ret_val="0"
log " ret_val = ${ret_val} "
if [[ ${ret_val} -eq 0 ]];then
log " ${curr_zip_type} files , processing !!! "
##dup_run_chk "${mlrun_fl}"
data_fl_exist=0
byt_chk=0
elif [[ ${ret_val} -eq 90 ]];then
log " No ${curr_zip_type} files , not processing !!! "
##dup_run_chk "${mlrun_fl}"
data_fl_exist=1
##exit 0
else
log " Error: byt chk does not match existing, not processing !!! "
##dup_run_chk "${mlrun_fl}"
##msg_str="Please check for Error in Log file"
##(echo "${msg_str}";uuencode $log_file $log_file;) | mailx -s "ALERT:$msg_str"
$MAIL_LIST
byt_chk=1
data_fl_exist=2
##exit 1
fi
##exit
####################################################################
# Get the files straight
####################################################################
if [[ ${data_fl_exist} -eq 0 ]];then
if [[ ${curr_zip_type} != 'LPSD' ]];then
cd $src_dir
else
cd $inb_dir
fi
touch efl

chmod $file_prm efl


if [[ $curr_zip_type = "TL" ]];then
lst_bs_nm="${outb_prfx}"
##elif [[ $curr_zip_type = "CC" ]];then
## lst_bs_nm="${outb_prfx}"
elif [[ $curr_zip_type = "CF" ]];then
lst_bs_nm="${outb_prfx}"
elif [[ $curr_zip_type = "LPSD" ]];then
lst_bs_nm="${outb_prfx}"
else
log "No relevant zip file"
exit 0
fi
lst_fl_rw_nm="${lst_bs_nm}_$$_rw_mstr_$(date +'%Y%m%d%H%M%S')_t.tmp"
lst_fl_nm="${lst_bs_nm}_$$_infl_mstr_tsak_$(date +'%Y%m%d%H%M%S')_t.tmp"
lst_fl_binfa_nm="${lst_bs_nm}_$$_bef_infl_mstr_tsbk_$(date +'%Y%m%d%H%M%S')_t.
tmp"
lst_fl_infa_nm="${lst_bs_nm}_$$_toinfa_mstr_tsck_$(date +'%Y%m%d%H%M%S')_t.tmp
"
if [[ ! -f ${lst_fl_rw_nm} ]];then
touch $lst_fl_rw_nm
chmod $file_prm $lst_fl_rw_nm
fi
touch $lst_fl_nm
chmod $file_prm $lst_fl_nm
if [[ ! -f ${lst_fl_infa_nm} ]];then
touch $lst_fl_infa_nm
chmod $file_prm $lst_fl_infa_nm
echo "mfl_name|mfl_cnt|mfl_src_loc|mfl_upld_tmstp|mfl_dwnld_tmstp|mfl_tgt_loc
|mfl_size|mfl_srce_rd_tmstp|rezip_fl_nm|rezip_fl_size|mfl_status|mfl_err_status"
> "${src_dir}${lst_fl_infa_nm}"
fi
dtl_fl_rw_nm="${lst_bs_nm}_$$_rw_dtl_$(date +'%Y%m%d%H%M%S')_t.tmp"
dtl_fl_nm="${lst_bs_nm}_$$_infl_dtl_tsak_$(date +'%Y%m%d%H%M%S')_t.tmp"
dtl_fl_binfa_nm="${lst_bs_nm}_$$_bef_infl_dtl_tsbk_$(date +'%Y%m%d%H%M%S')_t.t
mp"
dtl_fl_bsd_nm="${lst_bs_nm}_$$_bef_sd_dtl_tsck_$(date +'%Y%m%d%H%M%S')_t.tmp"
dtl_fl_infa_nm="${lst_bs_nm}_$$_toinfa_dtl_tsdk_$(date +'%Y%m%d%H%M%S')_t.tmp"
if [[ ! -f ${dtl_fl_rw_nm} ]];
then
touch $dtl_fl_rw_nm
chmod $file_prm $dtl_fl_rw_nm
fi
touch $dtl_fl_nm
chmod $file_prm $dtl_fl_nm
touch $dtl_fl_binfa_nm
chmod $file_prm $dtl_fl_binfa_nm
touch $dtl_fl_bsd_nm
chmod $file_prm $dtl_fl_bsd_nm
if [[ ! -f ${dtl_fl_infa_nm} ]];then
touch $dtl_fl_infa_nm
chmod $file_prm $dtl_fl_infa_nm
echo "mfl_name|dfl_name|dfl_src_loc|dtl_upload_tmstp|dfl_dwnld_tmstp|dfl_tgt_loc

|dfl_size|status|dfl_err_status" > "${src_dir}${dtl_fl_infa_nm}"


fi
cat ${inbound_daily_file} | while read line ;
do
files_exist=1
unzp_flag=0
cpy_flag=0
log " zip file = $zp_fl_nm "
log " Move forward to unzip.."
if [[ ${curr_zip_type} != 'LPSD' ]];then
log " Deriving Next CMPRS file LPSD.."
cd "${src_dir}"
#cd "${Src_dir}"
else
log " Deriving Next CMPRS file Others "
cd "${inb_dir}"
fi
zp_fl_nm="$line"
bs_nm=`basename $zp_fl_nm | cut -d"." -f1`
mfl_name=''
mfl_count=''
mfl_src_loc=''
mfl_upld_tmstp=''
mfl_dwnld_tmstp=''
mfl_tgt_loc=''
mfl_size=''
mfl_srce_rd_tmstp=''
rezip_fl_nm=''
rezip_fl_size=''
mfl_status=''
mfl_err_status=''
mfl_name="$zp_fl_nm"
log "mfl_name = $mfl_name"
mfl_count=`unzip -lo "${zp_fl_nm}" | tail -n1 | awk '{print $2;}'`
# mfl_count=`unzip -l "${line}" | tail -n1 | awk '{print $2;}'`
log "ln = $line"
log "mfl_count = $mfl_count"
mfl_src_loc="$inb_dir"
log "mfl_src_loc = $mfl_src_loc"
mfl_upld_tmstp=''
log "mfl_upld_tmstp = $mfl_upld_tmstp"
#mfl_dwnld_tmstp=`unzip -lo ${zp_fl_nm} | head -n4 | tail -n1 | awk '{printf $2;
printf " ";printf $3; print ":00";}'`
mfl_dwnld_tmstp=`unzip -l "${line}" | head -n4 | tail -n1 | awk '{printf $2;prin
tf " ";printf $3; print ":00";}'`
log "ln = $line"
log "mfl_dwnld_tmstp = $mfl_dwnld_tmstp"
mfl_tgt_loc="${zip_dir}"
log "mfl_tgt_loc = ${mfl_tgt_loc}"
mfl_size=`ls -l ${zp_fl_nm} | awk '{ print $5;}'`
# mfl_size=`ls -l "${line}" | awk '{ print $5;}'`
log "ln = $line"
log "mfl_size = $mfl_size"

mfl_srce_rd_tmstp=''
log "mfl_srce_rd_tmstp = $mfl_srce_rd_tmstp"
rezip_fl_nm=''
log " rezip_fl_nm = ${rezip_fl_nm}"
rezip_fl_size=''
log "rezip_fl_size = ${rezip_fl_size}"
mfl_status='SUCC'
log "mfl_status = $mfl_status"
#if [[ ${curr_zip_type} = 'CC' ]];then
#echo "$mfl_name|$mfl_count|$mfl_loc|$mfl_upld_tmstp|$mfl_dwnld_tmstp|$mfl_siz
e|$mfl_srce_rd_tmstp|$mfl_status|$mfl_err_status" >> "${unfold_zip_dir}${lst_fl_
rw_nm}"
#else
#echo "$mfl_name|$mfl_count|$mfl_loc|$mfl_upld_tmstp|$mfl_dwnld_tmstp|$mfl_siz
e|$mfl_srce_rd_tmstp|$mfl_status|$mfl_err_status" >> "${src_dir}${lst_fl_rw_nm}"
#fi
####################################################################
# Loop through the zip files
####################################################################
log " current zp_fl_nm = $zp_fl_nm "
##cat efl > $dtl_fl_rw_nm
##cat efl > $dtl_fl_nm
##cat efl > $dtl_fl_binfa_nm
if [[ ${curr_zip_type} = 'LPSD' ]];then
cd $inb_dir
else
log " Processing in ${src_dir} for ${curr_zip_type}"
cd "${src_dir}"
fi
# fi
##res=`unzip -o $zp_fl_nm > "${src_dir}$dtl_fl_rw_nm"`
res=`unzip -l $zp_fl_nm > "${src_dir}lstzip_${dtl_fl_rw_nm}"`
####################################################################
# Did they send directories
####################################################################
unzp_flag=0
log "grep -c '..\/.*' ${src_dir}${dtl_fl_nm}`"
if [[ `grep -c '..*\/.*' "${src_dir}lstzip_${dtl_fl_rw_nm}"` -gt 0 ]];
then
##if [[ `grep -c '..*creating:..*' $dtl_fl_nm` -gt 0 ]]; then
##log " unzp_flag = $unzp_flag "
#########
##cat $dtl_fl_nm >> test_folder.tmp
##########
## fi
unzp_flag=2
log " unzp_flag = $unzp_flag "
#mfl_name=''
#dfl_name=''
#dfl_count=''
#dfl_loc=''
#dfl_upld_tmstp=''
#dfl_dwnld_tmstp=''

#dfl_size=''
#dfl_srce_rd_tmstp=''
#dfl_status='FAIL'
#dtl_err_status=''
mfl_status='FAIL'
mfl_err_status='Have Folders in the zip_file'
if [[ $unzp_flag -ne $failed ]];
then
log "Error: Have Folders in the $zp_fl_nm , not proce
ssing."
if [[ ${curr_zip_type} = 'CC' ]];then
dir_name=`ls -lrt "${unfold_zip_dir}" | grep
-i '^d.*' | awk '!/SD_Case_Rezip/{print $9;}'`
else
dir_name=`ls -lrt "${src_dir}" | grep -i
'^d.*' | awk '!/SD_Case_Rezip/{print $9;}'`
fi
log " Captured the dir name = ${dir_name} "
fi
fi
##if [[ `grep -c '..*\.xml' $dtl_fl_rw_nm` -eq 0 ]]; then
log "grep -c ..*\.${fl_extn_val} ${src_dir}$dtl_fl_rw_nm"
if [[ ${unzp_flag} -eq 0 ]];then
res=`unzip -o $zp_fl_nm > "${src_dir}$dtl_fl_rw_nm"`
if [[ `grep -c "..*\.${fl_extn_val}" "${src_dir}$dtl_fl_rw_nm"
` -eq 0 ]]; then
unzp_flag=1
#mfl_name=''
#dfl_name=''
#dfl_count=''
#dfl_loc=''
#dfl_upld_tmstp=''
#dfl_dwnld_tmstp=''
#dfl_size=''
#dfl_srce_rd_tmstp=''
dfl_status='FAIL'
dtl_err_status=''
mfl_status='FAIL'
mfl_err_status='unable to unzip or no xml files'
if [[ $unzp_flag -ne $failed ]];
then
log "Error: unable to unzip $zp_fl_nm or no xm
l files "
fi
else
########################################################
############
# Loop through the xml files
########################################################
############
unzp_flag=0
sed -e 's/Archive://g' -e 's/ extracting://g' -e 's/ infla
ting://g' "${src_dir}${dtl_fl_rw_nm}" > "${src_dir}${dtl_fl_nm}"
#########
##cat $dtl_fl_nm >> test_folder.tmp
##########
log " UnZip task "
log " unzp_flag = $unzp_flag "

fi
fi
#########
## Enter values to the master file
##########
##mfl_name|mfl_cnt|mfl_src_loc|mfl_upld_tmstp|mfl_dwnld_tmstp|mfl_tgt
_loc|mfl_size|mfl_srce_rd_tmstp|rezip_fl_nm|rezip_fl_size|mfl_status|mfl_err_sta
tus"
echo "$mfl_name|$mfl_count|$mfl_src_loc|$mfl_upld_tmstp|$mfl_dwnld_tmstp|$mfl
_tgt_loc|$mfl_size|$mfl_srce_rd_tmstp|$rezip_fl_nm|$rezip_fl_size|$mfl_status|$m
fl_err_status" >> "${src_dir}${lst_fl_rw_nm}"
if [[ $unzp_flag -eq 0 ]];then
log " process ${fl_extn_val} list..build the doc list"
##
cat efl > $tmp_fl_rw_nm
##
cat efl > $tmp_fl_nm
## cat $dtl_fl_nm | while read line
awk 'NR>=2{print;}' "${src_dir}${dtl_fl_nm}" | while read line
;
do
unzp_flag=0
mfl_name=''
dfl_name=''
dfl_count=''
dfl_src_loc=''
dfl_upld_tmstp=''
dfl_dwnld_tmstp=''
dfl_tgt_loc=''
dfl_size=''
dfl_srce_rd_tmstp=''
dfl_status=''
dtl_err_status=''
#echo $line
if [[ $zp_fl_nm != $line ]];then
##echo "$zp_fl_nm|$line|" >> $tmp_fl_r
w_nm
mfl_name="${zp_fl_nm}"
log "mfl_name = $mfl_name"
if [[ $curr_zip_type = 'TL' ]];then
dfl_name="${line}"
elif [[ $curr_zip_type = 'LPSD' ]];then
dfl_name="${line}"
else
##is_dir=`echo ${line}
| awk -F'/' '/..*\/..*/{print $0;}' | sed -e 's/..*\///g'`
##if [[ -n ${is_dir} ]];
then
##dfl_name=`echo ${lin
e} | awk -F'/' '/..*\/..*/{print $0;}' | sed -e 's/..*\///g'`
##else
dfl_name="${line}"
##fi
log " dfl_name = $dfl
_name "
fi
log "dfl_name = $dfl_name"

dfl_src_loc="${inb_dir}"
log "dfl_src_loc = $dfl_src_loc"
dfl_upld_tmstp=''
log "dfl_upld_tmstp = $dfl_upld_tmstp"
dfl_dwnld_tmstp=`unzip -lo ${zp_fl_nm} | head -n4 | tail -n1 | a
wk '{printf $2;printf " ";printf $3; print ":00";}'`
log "dfl_dwnld_tmstp = $dfl_dwnld_tmst
p"
extn=`echo $line | cut -d"." -f2`
if [[ $curr_zip_type = 'TL' ]];then
dfl_size=`unzip -l "${zp_fl_n
m}" | awk -F'.' -v var="$line" '$0 ~ var' | awk '{print $1;}'| head -n1`
elif [[ $curr_zip_type = 'LPSD' ]];the
n
dfl_size=`unzip -l "${zp_fl_n
m}" | awk -F'.' -v var="$line" '$0 ~ var' | awk '{print $1;}'| head -n1`
else
dfl_size=`unzip -l "${zp_fl_nm}"
| awk '/..*\..*/{print $0;}' | awk '/..*\:/{print $0;}' | awk '!/..*\//{print
$0;}' |awk -F'.' -v var="$line" '$0 ~ var' | awk '{print $1;}' | head -n1`
fi
log "dfl_size = $dfl_size"
## fi
dfl_srce_rd_tmstp=''
log "dfl_srce_rd_tmstp = $dfl_srce_rd_
tmstp"
dfl_tgt_loc="${xml_dir}"
log "dfl_tgt_loc = $dfl_tgt_loc"
if [[ $dfl_status != 'FAIL' ]];then
dfl_status='SUCC'
fi
log "dfl_status = $dfl_status"
dtl_err_status=''
log "dtl_err_status = $dtl_err_status"
####
###Note changing to add tmstp
####
dfl_name="${line}"
rn_dtl_fl=`echo ${dfl_name} | cut -d"
." -f1`
blss_dtl_fl_nm="${rn_dtl_fl}_$(date +'%Y%m%d%H%M%S').
txt"
dfl_name="${blss_dtl_fl_nm}"
mv ${line} ${blss_dtl_fl_nm}
log "dfl_name = ${blss_dtl_fl_nm}, aft
er rnm"
if [[ -n `echo "${dfl_name}" | cut -d".
" -f2` ]];then
##echo "$mfl_name|$dfl_name|$dfl_loc|$dt
l_upld_tmstp|$dfl_dwnld_tmstp|$dfl_size|$dfl_srce_rd_tmstp|$dfl_status|$dfl_err_
status" >> $dtl_fl_binfa_nm
if [[ ${curr_zip_type} = 'CC' ]];then
echo "$mfl_name|$dfl_name|$dfl_src_loc|$
dtl_upld_tmstp|$dfl_dwnld_tmstp|$dfl_tgt_loc|$dfl_size|$dfl_status|$dfl_err_stat
us" >> "${src_dir}${dtl_fl_binfa_nm}"
else

echo "$mfl_name|$dfl_name|$dfl_src_loc|$
dtl_upld_tmstp|$dfl_dwnld_tmstp|$dfl_tgt_loc|$dfl_size|$dfl_status|$dfl_err_stat
us" >> "${src_dir}${dtl_fl_binfa_nm}"
fi
fi
fi
done
fi
########################################################
############
# Detail the rezip process
########################################################
############
log " Enter Next file"
done
##if [[ `wc -l $xptn_fl_nm | awk '{print $1;}'` -ne $succss ]];then
##
log "mail to support on the exception report"
##fi
log " Current Value of files_exist = ${files_exist} "
log " Current Value of pwd = `pwd`, curr_zip_type = ${curr_zip_type} "
####################################################################
# Detail the XML files for Infa Job Need to work from from here
####################################################################
#if [[ "${curr_zip_type}" = "LPSD" ]];then
##cat $dtl_fl_binfa_nm | cut -d"|" -f2 | grep '.*\.xml' > $infa_lst_fil
e ##infa_final.lst
#cd "${inb_dir}/"
#log " currently in ${scr_dir} for ${curr_zip_type} "
#elif [[ "${curr_zip_type}" = "CC" ]];then
##cd "${unfold_zip_dir}/"
#cd "${src_dir}/"
#log " currently in ${unfold_zip_dir} for ${curr_zip_type} "
#else
#cd "${src_dir}/"
#log " currently in ${src_dir} for ${curr_zip_type} "
#fi
cd "${src_dir}"
if [[ ${files_exist} -ne 0 ]];then
##sed -e "s/[^|]*/\'&\'/g" $lst_fl_rw_nm > $lst_fl_nm ##$lst_
fl_infa_nm > mstr_file
##sed -e "s/[^|]*/\'&\'/g" $dtl_fl_binfa_nm > $dtl_fl_bsd_nm
## > dtl_file
#############################
## commented on sund 1102
log " Current Value of files_exist = ${files_exist} "
log " Current Value of pwd = `pwd`, curr_zip_type = ${curr_zip_
type} "
cat "${src_dir}${lst_fl_rw_nm}" > "${src_dir}${lst_fl_nm}"
cat "${src_dir}${dtl_fl_binfa_nm}" > "${src_dir}${dtl_fl_bsd_n
m}"
##########################################

## The below two should be the dest files


cat "${src_dir}${lst_fl_nm}" >> "${src_dir}${lst_fl_infa_nm}"
cat "${src_dir}${dtl_fl_bsd_nm}" >> "${src_dir}${dtl_fl_infa_nm
}"
##final_mstr_bs=`basename ${lst_fl_infa_nm} | cut -d"." -f1`
##final_dtl_bs=`basename ${dtl_fl_infa_nm} | cut -d"." -f1`
final_mstr="${src_dir}${outb_prfx}_$$_CMPRS_$(date +'%Y%m%d%H%M
%S').tmp"
final_dtl="${src_dir}${outb_prfx}_$$_DTL_$(date +'%Y%m%d%H%M%S'
).tmp"
cat "${src_dir}${lst_fl_infa_nm}" >> "${final_mstr}"
cat "${src_dir}${dtl_fl_infa_nm}" >> "${final_dtl}"
################################################################
####
# These are final files
################################################################
####
if [[ -f "${final_mstr}" ]];then
mv "${final_mstr}" ${infa_junct_dir}
log " move ${final_mstr} to folder ${infa_junct_dir} "
fi
if [[ -f "${final_dtl}" ]];then
##cat "${final_dtl}" | cut -d"|" -f2 | grep '.*\.txt' > $infa_
lst_file ##infa_final.lst
##log " cat $final_dtl to $infa_lst_file "
cat "${final_dtl}" | cut -d"|" -f2 > "${all_mov_file}" ##inf
a_final.lst
log " cat $final_dtl to folder ${all_mov_file}"
mv "${final_dtl}" ${infa_junct_dir}
log " move ${final_dtl} to folder ${infa_junct_dir} "
else
log " Error: All steps not happened"
fi
else
log " No files exist!!"
fi
####################################################################
# Move the needed 7 txt files after replacing the cidela charecter
####################################################################
cd ${lpsd_inb_dir}
## br_fl_cnt=`find . \( ! -name . -prune \) -type f -name "${brow_srch_str}*.t
xt" -print | wc -l | awk '{print $1;}'`
## if [[ $br_fl_cnt -ne 0 ]];then
## for br_fl in $(find . \( ! -name . -prune \) -type f -name "${bro
w_srch_str}*.txt" -print | sed -e 's/..*\///g');do
##
sed -e 's/ //g' -e 's/\(^ \)//g' -e 's/ $//g' ${br_fl} > crm_${br_fl}
##
log " replaced char from ${br_fl} to crm_${br_fl} "
##
if [[ -f crm_${br_fl} ]];then
##
##
br_fl} "
##

mv crm_${br_fl} ${lpsd_outb_dir}${br_fl}
log " moved the file crm_${br_fl} to ${lpsd_outb_dir}${
else

##
log " Error: Cannot move the file crm_${br_fl} to ${lps
d_outb_dir}${br_fl} "
##
fi
## log " Borrower file(s) moved. "
## done
## else
## touch "${brow_tch_fl}"
## chmod $file_prm "${brow_tch_fl}"
##echo "BorrowerInfoIdentifierRefInfoIdentifierFirstNameMiddleNameLastNameAdd
ressLine1AddressLine2CityStateZipHomePhoneWorkPhoneFaxNumberEmailAddressCompanyComm
tedDateModifiedDateLoaninfoidentifierBorrowerType " > ${brow_tch_fl}
## mv ${brow_tch_fl} ${lpsd_outb_dir}
## fi

form_fl_cnt=`find . \( ! -name . -prune \) -type f -name "${form_srch_str}*.


txt" -print | wc -l | awk '{print $1;}'`
if [[ $form_fl_cnt -ne 0 ]];then
for fr_fl in $(find . \( ! -name . -prune \) -type f -name "${form_
srch_str}*.txt" -print | sed -e 's/..*\///g');do
sed -e 's/ //g' -e 's/\(^ \)//g' -e 's/ $//g' ${fr_fl} > ${lpsd_outb_dir}cr
o_del_fl}_${fr_fl}
log " replaced char from ${fr_fl} to ${lpsd_outb_dir}crm_${to_de
l_fl}_${fr_fl} "
##if [[ -f ${lpsd_outb_dir}crm_${fr_fl} ]];then
##mv crm_${to_del_fl}_${fr_fl} ${lpsd_outb_dir}${fr_fl}
##log " moved the file crm_${fr_fl} to ${lpsd_outb_dir}
${fr_fl} "
##else
##log " Error: Cannot move the file crm_${fr_fl} to ${l
psd_outb_dir}${fr_fl} "
##fi
##log " Form file(s) moved. "
done
else
fl_nt_fnd=1
##touch "${form_tch_fl}"
##chmod $file_prm "${form_tch_fl}"
#alrdyecho "FormInfoIdentifier|RefInfoIdentifier|StepOrder|FormName|Ques
tion|Answer|CreatedDate|ModifiedDate|ActiveDDF|Datatype|DatatypeID|ProcInfoIdent
ifier|" > ${form_tch_fl}
#echo "FormInfoIdentifierRefInfoIdentifierStepOrderFormNameQuestionAnswerCreatedDa
teModifiedDateActiveDDFDatatypeDatatypeIDProcInfoIdentifier" > ${form_tch_fl}
#mv ${form_tch_fl} ${lpsd_outb_dir}
fi
## loan_fl_cnt=`find . \( ! -name . -prune \) -type f -name "${loan_srch_str}
*.txt" -print | wc -l | awk '{print $1;}'`
## if [[ $loan_fl_cnt -ne 0 ]];then
##
for ln_fl in $(find . \( ! -name . -prune \) -type f -name "${loan_
srch_str}*.txt" -print | sed -e 's/..*\///g' );do
## sed -e 's/ //g' -e 's/\(^ \)//g' -e 's/ $//g' ${ln_fl} > crm_${ln_fl}
##
log " replaced char from ${ln_fl} to crm_${ln_fl} "
##
if [[ -f crm_${ln_fl} ]];then
##
##
b_dir}${ln_fl} "

mv crm_${ln_fl} ${lpsd_outb_dir}${ln_fl}
log " moved the file crm_${ln_fl} to ${lpsd_out

##
else
##
log " Error: Cannot move the file crm_${ln_fl}
to ${lpsd_outb_dir}${ln_fl} "
##
fi
## log " $Loan File(s) moved. "
## done
##else
## touch "${loan_tch_fl}"
## chmod $file_prm "${loan_tch_fl}"
#alredyecho "LoanInfoIdentifier|ServicerRegion|LoanNumber|LoanOriginatio
nDate|FirstPaymentDate|NextPaymentDate|OriginalLoanAmount|NetAmountDue|CurrentAm
ountDue|OriginalInterestRate|CurrentInterestRate|LoanTerm|EscrowBalance|Principl
eInterestPayment|InterestCalculationMethod|PaymentFrequency|SuspenseBalance|Occu
panyStatus|PerDiem|LoanDueDate|LoanMaturityDate|MortgageInsuranceCertNo|Property
Address|PropertyCity|PropertyState|PropertyZip|CreatedDate|ModifiedDate|Portfoli
oIndicator|PriorServicerLoanNumber|HeritageIndicator|Activeidentifier|Actioninth
enameof|SuperclientvendorID|" > ${loan_tch_fl}
## echo "LoanInfoIdentifierServicerRegionLoanNumberLoanOriginationDateFirstPayment
DateNextPaymentDateOriginalLoanAmountNetAmountDueCurrentAmountDueOriginalInterestRateC
urrentInterestRateLoanTermEscrowBalancePrincipleInterestPaymentInterestCalculationMe
thodPaymentFrequencySuspenseBalanceOccupanyStatusPerDiemLoanDueDateLoanMaturityDateMor
gageInsuranceCertNoPropertyAddressPropertyCityPropertyStatePropertyZipCreatedDateModif
iedDatePortfolioIndicatorPriorServicerLoanNumberHeritageIndicatorActiveidentifierActi
oninthenameofSuperclientvendorID" > ${loan_tch_fl}
## mv ${loan_tch_fl} ${lpsd_outb_dir}
## fi

proc_fl_cnt=`find . \( ! -name . -prune \) -type f -name "${proc_srch_str}*.


txt" -print | wc -l | awk '{print $1;}'`
if [[ $proc_fl_cnt -ne 0 ]];then
for pr_fl in $(find . \( ! -name . -prune \) -type f -name "${proc_srch_st
r}*.txt" -print | sed -e 's/..*\///g' );do
sed -e 's/ //g' -e 's/\(^ \)//g' -e 's/ $//g' ${pr_fl} > ${lpsd_outb_dir}crm_${to_d
}_${pr_fl}
log " replaced char from ${pr_fl} to ${lpsd_outb_dir}crm
_${to_del_fl}_${pr_fl} "
##if [[ -f crm_${pr_fl} ]];then
##mv crm_${pr_fl} ${lpsd_outb_dir}${pr_fl}
##log " moved the file crm_${pr_fl} to ${lpsd_o
utb_dir}${pr_fl} "
##else
##log " Error: Cannot move the file crm_${pr_fl
} to ${lpsd_outb_dir}${pr_fl} "

##fi
##log " Proc file(s) moved. "
done
else
fl_nt_fnd=1
##touch "${proc_tch_fl}"
##chmod $file_prm "${proc_tch_fl}"
#alredyecho "ProcInfoIdentifier|RefInfoIdentifier|ParentProcess|ProcessSequen
ce|ProcessName|StepDescription|StepOrder|DueDate|StepCompletion|DateClosed|Creat
edDate|ModifiedDate|FID|SpikeID|CreatedBy|ModifiedBy|" ${proc_tch_fl}
##echo "ProcInfoIdentifierRefInfoIdentifierParentProcessProcessSequenceProcessNam
eStepDescriptionStepOrderDueDateStepCompletionDateClosedCreatedDateModifiedDateFIDSp
reatedByModifiedBy" > ${proc_tch_fl}
##mv ${proc_tch_fl} ${lpsd_outb_dir}
fi

proc_meta_fl_cnt=`find . \( ! -name . -prune \) -type f -name "${proc_meta_


srch_str}*.txt" -print | wc -l | awk '{print $1;}'`
if [[ $proc_meta_fl_cnt -ne 0 ]];then
for pm_lf in $(find . \( ! -name . -prune \) -type f -name "${proc_
meta_srch_str}*.txt" -print | sed -e 's/..*\///g');do
sed -e 's/ //g' -e 's/\(^ \)//g' -e 's/ $//g' ${pm_lf} > ${lpsd_outb_dir}cr
o_del_fl}_${pm_lf}
log " replaced char from ${pm_lf} to ${lpsd_outb
_dir}crm_${to_del_fl}_${pm_lf} "
##if [[ -f crm_${pm_lf} ]];then
##mv crm_${pm_lf} ${lpsd_outb_dir}${pm_l
f}
##log " moved the file crm_${pm_lf} to
${lpsd_outb_dir}${pm_lf} "
##else
##log " Error: Cannot move the file crm
_${pm_lf} to ${lpsd_outb_dir}${pm_lf} "
##fi
##log " ProcMetafile(s) moved. "
done
else
fl_nt_fnd=1
##touch "${proc_meta_tch_fl}"
##chmod $file_prm "${proc_meta_tch_fl}"
#alredyecho "RefInfoIdentifier|ForeclosureAttorney|ForeclosureAttorneyPhone|Ba
nkruptcyCaseNumber|BankruptcyChapter|BankruptcyStartDate|BankruptcyFilingDate|Ba
nkruptcyNoticeReceivedDate|BankruptcyFilingState|BankruptcyDistrict|BankruptcyDi
vision|BankruptcyPOCBarDate|DateEntered|DateModified|" > ${proc_meta_tch_fl}
#echo "RefInfoIdentifierForeclosureAttorneyForeclosureAttorneyPhoneBankruptcyCase
NumberBankruptcyChapterBankruptcyStartDateBankruptcyFilingDateBankruptcyNoticeReceiv
edDateBankruptcyFilingStateBankruptcyDistrictBankruptcyDivisionBankruptcyPOCBarDateDa
teEnteredDateModified" > ${proc_meta_tch_fl}
#mv ${proc_meta_tch_fl} ${lpsd_outb_dir}
fi

ref_info_fl_cnt=`find . \( ! -name . -prune \) -type f -name "${ref_info_srch


_str}*.txt" -print | wc -l | awk '{print $1;}'`
if [[ ${ref_info_fl_cnt} -ne 0 ]];then
for ref_fl in $(find . \( ! -name . -prune \) -type f -name "${ref
_info_srch_str}*.txt" -print | sed -e 's/..*\///g');do
sed -e 's/ //g' -e 's/\(^ \)//g' -e 's/ $//g' ${ref_fl} > ${lpsd_outb_dir}c
to_del_fl}_${ref_fl}
log " replaced char from ${ref_fl} to ${
lpsd_outb_dir}crm_${to_del_fl}_${ref_fl} "
##if [[ -f crm_${ref_fl} ]];then
##mv crm_${ref_fl} ${lpsd_outb_d
ir}${ref_fl}
##log " moved the file crm_${re
f_fl} to ${lpsd_outb_dir}${ref_fl} "
##else
##log " Error: Cannot move the f
ile crm_${ref_fl} to ${lpsd_outb_dir}${ref_fl} "
##fi
##log " RefInfofile(s) moved. "
done
else
fl_nt_fnd=1

##touch "${ref_tch_fl}"
##chmod $file_prm "${ref_tch_fl}"
#alredyecho "RefInfoIdentifier|LoanInfoIdentifier|AssignedVendor|ReferralStar
tDate|DateClosed|CreatedDate|ModifiedDate|Inherited|Owner|CloseReasonId|vendorId
|ProcessId|RailDescr|ParentProcess|ProcessSequence|ProcessName|" > ${ref_tch_fl}
##echo "RefInfoIdentifierLoanInfoIdentifierAssignedVendorReferralStartDateDateClo
sedCreatedDateModifiedDate|InheritedOwnerCloseReasonIdvendorIdProcessIdRailDescrParen
ocessProcessSequenceProcessName" > ${ref_tch_fl}
##mv ${ref_tch_fl} ${lpsd_outb_dir}
fi

drsmeta_fl_cnt=`find . \( ! -name . -prune \) -type f -name "${forminfo_drsmet


ainfo_srch_str}*.txt" -print | wc -l | awk '{print $1;}'`
if [[ ${drsmeta_fl_cnt} -ne 0 ]];then
for drs_fl in $(find . \( ! -name . -prune \) -type f -name "${form
info_drsmetainfo_srch_str}*.txt" -print | sed -e 's/..*\///g');do
sed -e 's/ //g' -e 's/\(^ \)//g' -e 's/ $//g' ${drs_fl} > ${lpsd_outb_dir}c
to_del_fl}_${drs_fl}
log " replaced char from ${drs_f
l} to ${lpsd_outb_dir}crm_${to_del_fl}_${drs_fl} "
##if [[ -f crm_${drs_fl}
]];then
##mv crm_${drs_fl} ${lps
d_outb_dir}${drs_fl}
##log " moved the file
crm_${drs_fl} to ${lpsd_outb_dir}${drs_fl} "

##else
##log " Error: Cannot mo
ve the file crm_${drs_fl} to ${lpsd_outb_dir}${drs_fl} "
##fi
##log " DRSmetafile(s) moved. "
done
else
fl_nt_fnd=1
##touch "${drsmeta_tch_fl}"
##chmod $file_prm "${drsmeta_tch_fl}"
##alredyecho "ProcInfoIdentifier|DRSFormInfoIdentifier|TabName|TabIsLock
ed|SectionName|FieldID|FieldLabel|FieldType|FieldValue|FieldMiddleValue|GridId|G
ridRowID|GridColHeader1|GridCol1|GridType1|GridColHeader2|GridCol2|GridType2|Gri
dColHeader3|GridCol3|GridType3|GridColHeader4|GridCol4|GridType4|GridColHeader5|
GridCol5|GridType5|GridColHeader6|GridCol6|GridType6|FormCreatedBy|FormModifiedB
y|FormCompletedBy|FormCompletedDate|TabSavedBy|TabSavedDate|CreatedDate|Modified
Date|" > ${drsmeta_tch_fl}
#echo "ProcInfoIdentifierDRSFormInfoIdentifierTabNameTabIsLockedSectionNameFieldI
DFieldLabelFieldTypeFieldValueFieldMiddleValueGridIdGridRowIDGridColHeader1GridCol1G
pe1GridColHeader2GridCol2GridType2GridColHeader3GridCol3GridType3GridColHeader4GridCo
idType4GridColHeader5GridCol5GridType5GridColHeader6GridCol6GridType6FormCreatedByFor
difiedByFormCompletedByFormCompletedDateTabSavedByTabSavedDateCreatedDateModifiedDate"
> ${drsmeta_tch_fl}
##mv ${drsmeta_tch_fl} ${lpsd_outb_dir}
fi
####################################################################
# Remove tmp files
####################################################################
cd ${lpsd_outb_dir}
if [[ ${fl_nt_fnd} -eq 0 ]];then
if [[ -f ${lpsd_outb_dir}crm_${to_del_fl}_${fr_fl} ]];then

mv crm_${to_del_fl}_${fr_fl} ${lpsd_outb_dir}${f
r_fl}
chmod $file_prm ${lpsd_outb_dir}${fr_fl}
log " moved the file crm_${to_del_fl}_${fr_fl}
to ${lpsd_outb_dir}${fr_fl} "
else
log " Error: Cannot move the file crm_${to_del_
fl}_${fr_fl} to ${lpsd_outb_dir}${fr_fl} "
fi
log " Form file(s) moved. "
if [[ -f ${lpsd_outb_dir}crm_${to_del_fl}_${pr_fl} ]];then
mv crm_${to_del_fl}_${pr_fl} ${lpsd_outb_dir}${p
r_fl}
chmod $file_prm ${lpsd_outb_dir}${pr_fl}
log " moved the file crm_${to_del_fl}_${pr_fl}
to ${lpsd_outb_dir}${pr_fl} "
else
log " Error: Cannot move the file crm_${to_del_
fl}_${pr_fl} to ${lpsd_outb_dir}${pr_fl} "
fi
log " Proc file(s) moved. "
if [[ -f ${lpsd_outb_dir}crm_${to_del_fl}_${pm_lf} ]];then
mv crm_${to_del_fl}_${pm_lf} ${lpsd_outb
_dir}${pm_lf}
chmod $file_prm ${lpsd_outb_dir}${pm_lf}
log " moved the file crm_${to_del_fl}_$
{pm_lf} to ${lpsd_outb_dir}${pm_lf} "
else
log " Error: Cannot move the file crm_$
{to_del_fl}_${pm_lf} to ${lpsd_outb_dir}${pm_lf} "
fi
log " ProcMetafile(s) moved. "
if [[ -f ${lpsd_outb_dir}crm_${to_del_fl}_${ref_fl} ]];then
mv crm_${to_del_fl}_${ref_fl} ${
lpsd_outb_dir}${ref_fl}
chmod $file_prm ${lpsd_outb_dir}${ref_fl}
log " moved the file crm_${to_d
el_fl}_${ref_fl} to ${lpsd_outb_dir}${ref_fl} "
else
log " Error: Cannot move the fil
e crm_${to_del_fl}_${ref_fl} to ${lpsd_outb_dir}${ref_fl} "
fi
log " RefInfofile(s) moved. "
if [[ -f ${lpsd_outb_dir}crm_${to_del_fl}_${drs_fl} ]];then
mv crm_${to_del_fl}_${dr
s_fl} ${lpsd_outb_dir}${drs_fl}
chmod $file_prm ${lpsd_outb_dir}${drs_fl}
log " moved the file cr
m_${to_del_fl}_${drs_fl} to ${lpsd_outb_dir}${drs_fl} "
else
log " Error: Cannot move
the file crm_${to_del_fl}_${drs_fl} to ${lpsd_outb_dir}${drs_fl} "
fi
log " DRSmetafile(s) moved. "

else
log " Error:${fl_nt_fnd} is not zero. "
#data_fl_exist=1
## need code to purge the files above.
if [[ -f ${lpsd_outb_dir}crm_${to_del_fl}_${fr_fl} ]];then
rm crm_${to_del_fl}_${fr_fl}
log " removed the file crm_${to_del_fl}_${fr_fl}
"
else
log " Error: Cannot remove the file crm_${to_de
l_fl}_${fr_fl} "
fi
log " Form file(s) moved. "
if [[ -f ${lpsd_outb_dir}crm_${to_del_fl}_${pr_fl} ]];then
rm crm_${to_del_fl}_${pr_fl}
log " removed the file crm_${to_del_fl}_${pr_fl
} "
else
log " Error: Cannot remove the file crm_${to_de
l_fl}_${pr_fl} "
fi
log " Proc file(s) moved. "
if [[ -f ${lpsd_outb_dir}crm_${to_del_fl}_${pm_lf} ]];then
rm crm_${to_del_fl}_${pm_lf}
log " removed the file crm_${to_del_fl}
_${pm_lf} "
else
log " Error: Cannot remove the file crm
_${to_del_fl}_${pm_lf} "
fi
log " ProcMetafile(s) moved. "
if [[ -f ${lpsd_outb_dir}crm_${to_del_fl}_${ref_fl} ]];then
rm crm_${to_del_fl}_${ref_fl}
log " removed the file crm_${to
_del_fl}_${ref_fl} "
else
log " Error: Cannot remove the f
ile crm_${to_del_fl}_${ref_fl} "
fi
log " RefInfofile(s) moved. "
if [[ -f ${lpsd_outb_dir}crm_${to_del_fl}_${drs_fl} ]];then
rm crm_${to_del_fl}_${dr
s_fl}
log " removed the file c
rm_${to_del_fl}_${drs_fl} "
else
log " Error: Cannot remo
ve the file crm_${to_del_fl}_${drs_fl} "
fi
log " DRSmetafile(s) moved. "
fi
fi

####################################################################
# Move XML Files
####################################################################
##for fl in $(find . -type f \( -name "*.xml" -o -name "*.do" -o -name "*.tmp" \
) -print)
################################################################
####
# Also Move XML list and all mov list
################################################################
####
if [[ -f ${infa_lst_file} ]];then
mv ${infa_lst_file} "/docdata/DefaultIT/DocMgmt/${user_env}/${mo
d_dir}/SrcFiles/"
fi
if [[ -f ${all_mov_file} ]];then
mv ${all_mov_file} "/docdata/DefaultIT/DocMgmt/${user_env}/${mod
_dir}/SrcFiles/"
fi

##ksh /docdata/DefaultIT/DocMgmt/${user_env}/Scripts/sd_archiving_zip_xml_files.
sh 'ARCHDTS' 'DTS' "${curr_zip_type}" "${to_del_fl}"
ksh /docdata/DefaultIT/DocMgmt/${user_env}/Scripts/sd_archive_bulk_files.sh /doc
data/DefaultIT/DocMgmt/${user_env}/LPSD/InboundFiles '*.zip *.txt' 'LPSD' /docda
ta/DefaultIT/DocMgmt/${user_env}/LPSD/Archive

####################################################################
# Remove tmp files
####################################################################
cd $inb_dir
if [[ -f ${infa_lst_file} ]];then
rm -rf ${infa_lst_file}
log " removed the file ${infa_lst_file} "
fi
if [[ -f ${all_mov_file} ]];then
rm -rf ${all_mov_file}
log " removed the file ${all_mov_file} "
fi
if [[ -f ${inbound_daily_file} ]];then
rm -rf ${inbound_daily_file}
log " removed the file ${inbound_daily_file} "
fi
if [[ -f ${inbound_daily_orig_file} ]];then
rm -rf ${inbound_daily_orig_file}
log " removed the file ${inbound_daily_orig_file} "
fi
for dl_fl in $(find . \( ! -name . -prune \) -type f -name "*${to_del_fl}*_t.tmp
" -print);do
rm -rf $dl_fl
log " removed the file ${dl_fl} "
done

####################################################################
# Remove rest of tmp files
####################################################################
cd $src_dir
for dl_fl in $(find . \( ! -name . -prune \) -type f -name "*${to_del_fl}*_t.tmp
" -print);do
rm -rf $dl_fl
log " removed the file ${dl_fl} "
done
####################################################################
# Remove tmp from cmp files
####################################################################
cd $infa_junct_dir
##to_del_fl=`echo "${current_log}" | awk -F'/' '{print $8;}' | cut -d'_' -f5`
##log " pruing the temp file(s) for ${to_del_fl} "
for dl_fl in $(find . \( ! -name . -prune \) -type f -name "*${to_del_fl}*bytcmp
*.tmp" -print);do
rm -rf $dl_fl
log " removed the file ${dl_fl} "
done
####################################################################
# Loop through the xml files
####################################################################
if [[ `grep -c 'Error:.*' ${log_file}` -ne 0 ]];then
msg_str="Please check for Error in Log file"
(echo "${msg_str}";uuencode $log_file $log_file;) | mailx -s "ALERT:$msg_str" $M
AIL_LIST
fi
####################################################################
# multi job control condition
####################################################################
dup_run_chk "${mlrun_fl}"
fi
log "Script Complete.."
if [[ $data_fl_exist -eq 0 && $byt_chk -eq 0 ]];then
status=0
else
status=1
fi
exit $status

S-ar putea să vă placă și