|
Search Forums |
Tag Search |
Advanced Search |
Quick Links |
Contact Us |
Forum Rules |
Today's Posts |
FAQ |
Pictures & Albums |
All Albums |
Miscellaneous |
What is My IP |
Whois |
Mark Forums Read |
#!/usr/bin/ksh ######################################################################### # script name: cdg_file_load.ksh # Created : March 29, 2013 # Author : David Ayotte # # Find new files for the file type and period that is passed in in the form # of a lookup key that is used to determine what directory and file masks # to look for. The lookup file is $FP_ENV/CDG_Lookup.txt # # Revision History: (include date, username, and brief description in # descending order) ######################################################################### # # Function definitions # # Usage Function # function usage_msg { echo "\n---> Usage: \n" echo "---> cdg_file_load.ksh -k< key > " echo " -k is a Key lookup value in the $FP_ENV/CDG_Lookup.txt file." # grep -v "#" $lookupFile | cut -d"|" -f1 | sort | uniq echo "" exit_func } # # Exit Function # function exit_func { echo "---> Running exit function..." exit $rc # update_job_table only when $rc != 0 } # # Make sure the file is static # function is_file_changing { baseName=`basename ${sourceFile}` timeFile=${FP_LOGDIR}/${baseName}_tmstp touch ${timeFile} echo "Time Compare file is ${timeFile}" echo "---> Sleeping to see if file changes in 20 seconds " sleep 20 while [ ${sourceFile} -nt ${timeFile} ] do touch ${timeFile} echo "-> Sleeping 20 more seconds...attempt $i" sleep 20 let i=$i+1 if [ $i -gt 60 ] # I am sick of waiting then rc=24 exit_func fi done echo "---> File is found and not changing. " } # # Execute Informatica workflow to load new file. # function load_file { # # Determine that file is not changing. # # TEST is_file_changing # # Creat link to file, much quicker than copying to local name. # if [ -f ${FP_FTP_DOWN}/${staticFile} or -h ${FP_FTP_DOWN}/${staticFile} ] then rm ${FP_FTP_DOWN}/${staticFile} # no need to check return code, the ln command will fail. fi echo "---> Creating link from static file name ${staticFile} " ln -s ${sourceFile} ${FP_FTP_DOWN}/${staticFile} rc=$? if [ $rc -ne 0 ] then echo "---> ERROR: Unable to create link. " rc=30 exit_func fi # # Execute Informatica workflow # export parmFile=${FP_PARMFILES}/${workFlow}.par echo "---> Executing Informatica workflow ${workFlow} " cmd="pmcmd startworkflow -wait -sv ${FP_SERVICE} -d ${FP_DOMAIN} -uv FP_INF_USER -pv FP_INF_PSWD " cmd=$cmd" -paramfile ${parmFile} -f ${FP_FOLDER} ${workFlow} " echo "--> Command: $cmd" $cmd rc=$? if [ $rc -ne 0 ] then echo "---> ERROR: Error executing Informatica Workflow." rc=30 exit_func fi } # # Determine if this file has been loaded already. # function has_file_been_loaded { alreadyLoaded=0 # False - File has not been loaded cnt=`grep -c ${sourceFile} ${cdgFileList}` if [ $cnt -eq 0 ] then echo "---> This file has not been loaded " else # echo "---> This file has already been loaded " alreadyLoaded=1 fi } # # Check for files in a directory # # More like, process a file mask for a directory for a workflow. Several file types # can be found in each directory, but must be processed by a different Informatica # workflow. # function process_a_directory { echo "Checking ${FP_CDG_CFR}${searchPath}/${searchMask}" # for sourceFile in `ls -1 ${FP_CDG_CFR}${searchPath}/${searchMask}*` for sourceFile in `find ${FP_CDG_CFR}${searchPath} -name "${searchMask}" -type f -mtime -5` do echo "---> Checking $sourceFile " has_file_been_loaded if [ ${alreadyLoaded} -eq 0 ] then # for Jeff to add later update_job_table load_file let fileCntr=$fileCntr+1 echo $sourceFile >> ${cdgFileList} # So we won't load it again # for Jeff to add later update_job_table fi done } # # extract values from lookup record # function get_values { # Extract values searchPath=`echo $rec | cut -d"|" -f2` searchMask=`echo $rec | cut -d"|" -f3` staticFile=`echo $rec | cut -d"|" -f4` workFlow=`echo $rec | cut -d"|" -f5` # Display values echo "\n---> Search Path = $searchPath" echo "---> Search Mask = $searchMask" echo "---> Static File = $staticFile" echo "---> Workflow = $workFlow" } # # Find new files and load them # function find_and_load_new_files { echo "---> attempting to process $keyValue " lookupValuesFound=0 for rec in `grep "^${keyValue}|" $lookupFile` do get_values let lookupValuesFound=$lookupValuesFound+1 process_a_directory done } # # Command Line Parsing # export fileCntr=0 export lookupFile=${FP_ENV}/CDG_Lookup.txt export cdgFileList=$FP_FTP_DOWN/cdg_loaded_files.txt # list of files already loaded. # remove this next line after testing is done # # export FP_CDG_CFR=/fpapps/op/qa/ftproot/cdgtest # if [ $# -ne 1 ] then usage_msg fi while getopts "k:" option do case "$option" in k) keyValue="$OPTARG" ;; [?]) usage_msg ;; esac done # # if [ "$keyValue" = "" ] then exit_func fi # find_and_load_new_files # if [ $lookupValuesFound -eq 0 ] then echo "\n---> ERROR: No values found in lookup file. " rc=30 else echo "\n---> $lookupValuesFound lookup values found" fi # echo "\n---> Total Files processed is $fileCntr \n" exit_func
aCR3027 - OP - Operational Data Store - Sophia Decommission - CDG Processing notes Create date: June 20, 2013 Author: David Ayotte UNIX Systems: Development: Host: nh1a7t05 - Unix ID: opdev QA: Host: nh1a7t05 - Unix ID: opqa Production: Host: nh1a7p09 - Unix ID: opuser Informatica Environments: Development: Repository: FP_DEV_REPO - Folder: OP QA: Repository: FP_QA_REPO - Folder: OP Production: Repository: FP_PRD_REPO_P04 - Folder: OP Project Goal: Load files from CDG directories for multiple file types at different times of the month (cycles). These cycles are listed below: CYCLE04 CYCLE06 CYCLE07 CYCLE10 CYCLE13 CYCLE19 CYCLE25 DAILY EOM Each cycle corresponds to a Control-M calendar with similar names as shown in the following diagram. The calendars will determine when to check for files in the directories that correspond to the cycles defined above: A lookup file called CDG_Lookup.txt is used to drive the process. This file resides in /fpapps/op/qa/env on nh1a7t05. UNIX scripting and Control-M work is not done in the development directories due to the environment not being static. Below are the entries in the lookup file for CYCLE04. This is a pipe “|” delimited file with the fields from left to right being: Key | Directory to check | File Mask to check | Static File | Informatica workflow | Calendar (for reference only) Key: This is to be passed to the script on the command line of the Control-M job. The script will use this to determine what and how to process this cycle. Directory to check: These are the subdirectories under /fpapps/cfr/CDG that the script will check for files to load. File Mask to Check: Files found that match this format will be loaded. Static File: Each file that is found to match the format mask will be copied, one at a time, to the static file name. After this copy, the Informatica Workflow will run and load the static file name. Informatica Workflow: This is the name of the Informatica workflow that will run to load the static file. Calendar: This is for reference only. When this has a value of multiple, you may find this directory and file mask under more than one cycle. CYCLE04|/Reports/0570/04th|AC3.C*.AC0020.D*.T*.CSV|AC0020.CSV|WF_LOAD_FF_TEMP_AC0020|CDG_Cycle4| CYCLE04|/Reports/0570/04th|AC3.C*.AC0025.D*.T*.CSV|AC0025.CSV|WF_LOAD_FF_TEMP_AC0025|CDG_Cycle4| CYCLE04|/Reports/0570/04th|AC3.C*.AC0068.D*.T*.CSV|AC0068.CSV|WF_LOAD_FF_TEMP_AC0068|CDG_Cycle4| CYCLE04|/Reports/0570/04th|AC3.C*.AC0730.D*.T*.CSV|AC0730.CSV|WF_LOAD_FF_TEMP_AC0730|CDG_Cycle4| CYCLE04|/Reports/0570/04th|AC3.C*.AC0760.D*.T*.CSV|AC0760.CSV|WF_LOAD_FF_TEMP_AC0760|CDG_Cycle4| CYCLE04|/Reports/0570/04th|AC3.C*.AC0780.D*.T*.CSV|AC0780.CSV|WF_LOAD_FF_TEMP_AC0780|CDG_Cycle4| CYCLE04|/Reports/0571/04th|AC3.C*.AC0020.D*.T*.CSV|AC0020.CSV|WF_LOAD_FF_TEMP_AC0020|CDG_Cycle4| CYCLE04|/Reports/0571/04th|AC3.C*.AC0025.D*.T*.CSV|AC0025.CSV|WF_LOAD_FF_TEMP_AC0025|CDG_Cycle4| CYCLE04|/Reports/0571/04th|AC3.C*.AC0068.D*.T*.CSV|AC0068.CSV|WF_LOAD_FF_TEMP_AC0068|CDG_Cycle4| CYCLE04|/Reports/0571/04th|AC3.C*.AC0730.D*.T*.CSV|AC0730.CSV|WF_LOAD_FF_TEMP_AC0730|CDG_Cycle4| CYCLE04|/Reports/0571/04th|AC3.C*.AC0760.D*.T*.CSV|AC0760.CSV|WF_LOAD_FF_TEMP_AC0760|CDG_Cycle4| CYCLE04|/Reports/0571/04th|AC3.C*.AC0780.D*.T*.CSV|AC0780.CSV|WF_LOAD_FF_TEMP_AC0780|CDG_Cycle4| CYCLE04|/Reports/0572/04th|AC3.C*.AC0020.D*.T*.CSV|AC0020.CSV|WF_LOAD_FF_TEMP_AC0020|CDG_Cycle4| CYCLE04|/Reports/0572/04th|AC3.C*.AC0025.D*.T*.CSV|AC0025.CSV|WF_LOAD_FF_TEMP_AC0025|CDG_Cycle4| CYCLE04|/Reports/0572/04th|AC3.C*.AC0068.D*.T*.CSV|AC0068.CSV|WF_LOAD_FF_TEMP_AC0068|CDG_Cycle4| CYCLE04|/Reports/0572/04th|AC3.C*.AC0730.D*.T*.CSV|AC0730.CSV|WF_LOAD_FF_TEMP_AC0730|CDG_Cycle4| CYCLE04|/Reports/0572/04th|AC3.C*.AC0760.D*.T*.CSV|AC0760.CSV|WF_LOAD_FF_TEMP_AC0760|CDG_Cycle4| CYCLE04|/Reports/0572/04th|AC3.C*.AC0780.D*.T*.CSV|AC0780.CSV|WF_LOAD_FF_TEMP_AC0780|CDG_Cycle4| CYCLE04|/Reports/0581/04th|AC3.C*.AC0020.D*.T*.CSV|AC0020.CSV|WF_LOAD_FF_TEMP_AC0020|CDG_Cycle4| CYCLE04|/Reports/0581/04th|AC3.C*.AC0025.D*.T*.CSV|AC0025.CSV|WF_LOAD_FF_TEMP_AC0025|CDG_Cycle4| CYCLE04|/Reports/0581/04th|AC3.C*.AC0068.D*.T*.CSV|AC0068.CSV|WF_LOAD_FF_TEMP_AC0068|CDG_Cycle4| CYCLE04|/Reports/0581/04th|AC3.C*.AC0730.D*.T*.CSV|AC0730.CSV|WF_LOAD_FF_TEMP_AC0730|CDG_Cycle4| CYCLE04|/Reports/0581/04th|AC3.C*.AC0760.D*.T*.CSV|AC0760.CSV|WF_LOAD_FF_TEMP_AC0760|CDG_Cycle4| CYCLE04|/Reports/0581/04th|AC3.C*.AC0780.D*.T*.CSV|AC0780.CSV|WF_LOAD_FF_TEMP_AC0780|CDG_Cycle4| CYCLE04|/Reports/0582/04th|AC3.C*.AC0020.D*.T*.CSV|AC0020.CSV|WF_LOAD_FF_TEMP_AC0020|CDG_Cycle4| CYCLE04|/Reports/0582/04th|AC3.C*.AC0025.D*.T*.CSV|AC0025.CSV|WF_LOAD_FF_TEMP_AC0025|CDG_Cycle4| CYCLE04|/Reports/0582/04th|AC3.C*.AC0068.D*.T*.CSV|AC0068.CSV|WF_LOAD_FF_TEMP_AC0068|CDG_Cycle4| CYCLE04|/Reports/0582/04th|AC3.C*.AC0730.D*.T*.CSV|AC0730.CSV|WF_LOAD_FF_TEMP_AC0730|CDG_Cycle4| CYCLE04|/Reports/0582/04th|AC3.C*.AC0760.D*.T*.CSV|AC0760.CSV|WF_LOAD_FF_TEMP_AC0760|CDG_Cycle4| CYCLE04|/Reports/0582/04th|AC3.C*.AC0780.D*.T*.CSV|AC0780.CSV|WF_LOAD_FF_TEMP_AC0780|CDG_Cycle4| CYCLE04|/Reports/0583/04th|AC3.C*.AC0020.D*.T*.CSV|AC0020.CSV|WF_LOAD_FF_TEMP_AC0020|CDG_Cycle4| CYCLE04|/Reports/0583/04th|AC3.C*.AC0025.D*.T*.CSV|AC0025.CSV|WF_LOAD_FF_TEMP_AC0025|CDG_Cycle4| CYCLE04|/Reports/0583/04th|AC3.C*.AC0068.D*.T*.CSV|AC0068.CSV|WF_LOAD_FF_TEMP_AC0068|CDG_Cycle4| CYCLE04|/Reports/0583/04th|AC3.C*.AC0730.D*.T*.CSV|AC0730.CSV|WF_LOAD_FF_TEMP_AC0730|CDG_Cycle4| CYCLE04|/Reports/0583/04th|AC3.C*.AC0760.D*.T*.CSV|AC0760.CSV|WF_LOAD_FF_TEMP_AC0760|CDG_Cycle4| CYCLE04|/Reports/0583/04th|AC3.C*.AC0780.D*.T*.CSV|AC0780.CSV|WF_LOAD_FF_TEMP_AC0780|CDG_Cycle4| CYCLE04|/Reports|Processed_AC3.C*.AC0877J.D*.T*.CSV|AC0877.CSV|WF_LOAD_FF_TEMP_AC0877|Multiple| The script to run the load is called cdg_file_load.ksh and resides in the following directory on nh1a7t05: /fpapps/op/qa/prod/scripts/cdg and in the following directory on nh1a8p04: /fpapps/op/prod/scripts/cdg The only command line option for the script is -k<key>, where key is the key value from the CDG_Lookup.txt file (such as CYCLE04). A sample command line for Control-M would look like this: batchjob OP %%JOBNAME ${FP_SCRIPTS}/cdg/cdg_file_load.ksh -eCYCLE04 The above command line example will work in QA and in production on nh1a8p04. Misc: A file called cdg_loaded_files.txt exists in the following directory on nh1a7t05: /fpapps/op/qa/ftproot/ftpdown The cdg_loaded_files.txt file contains a list of all files and the full directory to each file that has been loaded. This is updated after a file is loaded without errors. This way, if a load fails, it is not marked as loaded. The need for this file is because we do not have the ability to remove files from the cfr (Central File Repository). I suppose we could have built an entire archive directory structure that matches what is on the cfr, but this file should work okay for a long time. Since the find command in the load script only goes back five days, this file can eventually have old rows removed from the beginning. Much care should be taken before this is done and a script should probably be written to do this. For example, find all files on the cfr older than 5 days and remove them from this lookup file, and remove any files from this lookup that do not exist in the cfr.
# update_job_table only when $rc != 0
#!/usr/bin/ksh ######################################################################### # script name: cdg_file_load_test.ksh # Created : July 25, 2013 # Author : Brinjit Velu # # Find new files for the file type and period that is passed in in the form # of a lookup key that is used to determine what directory and file masks # to look for. The lookup file is $FP_ENV/CDG_Lookup.txt # # Revision History: (include date, username, and brief description in # descending order) ######################################################################### # # Function definitions # # Usage Function # function usage_msg { echo "\n---> Usage: \n" echo "---> cdg_file_load_test.ksh -k< key > " echo " -k is a Key lookup value in the $FP_ENV/CDG_Lookup.txt file." # grep -v "#" $lookupFile | cut -d"|" -f1 | sort | uniq echo "" exit_func } # # Exit Function # function exit_func { echo "---> Running exit function..." if [ $? -ne 0 ] then update_job_table fi exit $rc # update_job_table only when $rc != 0 } # # Make sure the file is static # function is_file_changing { baseName=`basename ${sourceFile}` timeFile=${FP_LOGDIR}/${baseName}_tmstp touch ${timeFile} echo "Time Compare file is ${timeFile}" echo "---> Sleeping to see if file changes in 20 seconds " sleep 20 while [ ${sourceFile} -nt ${timeFile} ] do touch ${timeFile} echo "-> Sleeping 20 more seconds...attempt $i" sleep 20 let i=$i+1 if [ $i -gt 60 ] # I am sick of waiting then rc=24 exit_func fi done echo "---> File is found and not changing. " } # # Execute Informatica workflow to load new file. # function load_file { # # Determine that file is not changing. # # TEST is_file_changing # # Creat link to file, much quicker than copying to local name. # if [ -f ${FP_FTP_DOWN}/${staticFile} or -h ${FP_FTP_DOWN}/${staticFile} ] then rm ${FP_FTP_DOWN}/${staticFile} # no need to check return code, the ln command will fail. fi echo "---> Creating link from static file name ${staticFile} " ln -s ${sourceFile} ${FP_FTP_DOWN}/${staticFile} rc=$? if [ $rc -ne 0 ] then echo "---> ERROR: Unable to create link. " rc=30 exit_func fi # # Execute Informatica workflow # export parmFile=${FP_PARMFILES}/${workFlow}.par echo "---> Executing Informatica workflow ${workFlow} " cmd="pmcmd startworkflow -wait -sv ${FP_SERVICE} -d ${FP_DOMAIN} -uv FP_INF_USER -pv FP_INF_PSWD " cmd=$cmd" -paramfile ${parmFile} -f ${FP_FOLDER} ${workFlow} " echo "--> Command: $cmd" $cmd rc=$? if [ $rc -ne 0 ] then echo "---> ERROR: Error executing Informatica Workflow." rc=30 exit_func fi } # # Determine if this file has been loaded already. # function has_file_been_loaded { alreadyLoaded=0 # False - File has not been loaded cnt=`grep -c ${sourceFile} ${cdgFileList}` if [ $cnt -eq 0 ] then echo "---> This file has not been loaded " else # echo "---> This file has already been loaded " alreadyLoaded=1 fi } # # Check for files in a directory # # More like, process a file mask for a directory for a workflow. Several file types # can be found in each directory, but must be processed by a different Informatica # workflow. # function process_a_directory { echo "Checking ${FP_CDG_CFR}${searchPath}/${searchMask}" # for sourceFile in `ls -1 ${FP_CDG_CFR}${searchPath}/${searchMask}*` for sourceFile in `find ${FP_CDG_CFR}${searchPath} -name "${searchMask}" -type f -mtime -5` do echo "---> Checking $sourceFile " has_file_been_loaded if [ ${alreadyLoaded} -eq 0 ] then function update_job_table { # for Jeff to add later update_job_table load_file let fileCntr=$fileCntr+1 echo $sourceFile >> ${cdgFileList} # So we won't load it again # for Jeff to add later update_job_table } fi done } # # extract values from lookup record # function get_values { # Extract values searchPath=`echo $rec | cut -d"|" -f2` searchMask=`echo $rec | cut -d"|" -f3` staticFile=`echo $rec | cut -d"|" -f4` workFlow=`echo $rec | cut -d"|" -f5` # Display values echo "\n---> Search Path = $searchPath" echo "---> Search Mask = $searchMask" echo "---> Static File = $staticFile" echo "---> Workflow = $workFlow" } # # Find new files and load them # function find_and_load_new_files { echo "---> attempting to process $keyValue " lookupValuesFound=0 for rec in `grep "^${keyValue}|" $lookupFile` do get_values let lookupValuesFound=$lookupValuesFound+1 process_a_directory done } # # Command Line Parsing # export fileCntr=0 export lookupFile=${FP_ENV}/CDG_Lookup.txt export cdgFileList=$FP_FTP_DOWN/cdg_loaded_files.txt # list of files already loaded. # remove this next line after testing is done # # export FP_CDG_CFR=/fpapps/op/qa/ftproot/cdgtest # if [ $# -ne 1 ] then usage_msg fi while getopts "k:" option do case "$option" in k) keyValue="$OPTARG" ;; [?]) usage_msg ;; esac done # # if [ "$keyValue" = "" ] then exit_func fi # find_and_load_new_files # if [ $lookupValuesFound -eq 0 ] then echo "\n---> ERROR: No values found in lookup file. " rc=30 else echo "\n---> $lookupValuesFound lookup values found" fi # echo "\n---> Total Files processed is $fileCntr \n" exit_func
#!/usr/bin/ksh # Note 1 ######################################################################### # script name: cdg_file_load_test.ksh # Created : July 25, 2013 # Author : Brinjit Velu # # Find new files for the file type and period that is passed in in the form # of a lookup key that is used to determine what directory and file masks # to look for. The lookup file is $FP_ENV/CDG_Lookup.txt # # Revision History: (include date, username, and brief description in # descending order) ######################################################################### # # Function definitions ... ... ... # # Exit Function # function exit_func { echo "---> Running exit function..." if [ $? -ne 0 ] # Note 2 then update_job_table fi exit $rc # update_job_table only when $rc != 0 } ... ... ... # # Check for files in a directory # # More like, process a file mask for a directory for a workflow. Several file types # can be found in each directory, but must be processed by a different Informatica # workflow. # function process_a_directory { echo "Checking ${FP_CDG_CFR}${searchPath}/${searchMask}" # for sourceFile in `ls -1 ${FP_CDG_CFR}${searchPath}/${searchMask}*` for sourceFile in `find ${FP_CDG_CFR}${searchPath} -name "${searchMask}" -type f -mtime -5` do echo "---> Checking $sourceFile " has_file_been_loaded if [ ${alreadyLoaded} -eq 0 ] then function update_job_table { # Note 3 # for Jeff to add later update_job_table load_file let fileCntr=$fileCntr+1 echo $sourceFile >> ${cdgFileList} # So we won't load it again # for Jeff to add later update_job_table } fi done } ... ... ... # # Command Line Parsing # export fileCntr=0 export lookupFile=${FP_ENV}/CDG_Lookup.txt export cdgFileList=$FP_FTP_DOWN/cdg_loaded_files.txt # list of files already loaded. # remove this next line after testing is done # # export FP_CDG_CFR=/fpapps/op/qa/ftproot/cdgtest # if [ $# -ne 1 ] # Note 4 then usage_msg fi while getopts "k:" option do case "$option" in k) keyValue="$OPTARG" ;; [?]) usage_msg ;; esac done # # if [ "$keyValue" = "" ] then exit_func fi # find_and_load_new_files # if [ $lookupValuesFound -eq 0 ] then echo "\n---> ERROR: No values found in lookup file. " rc=30 else echo "\n---> $lookupValuesFound lookup values found" fi # echo "\n---> Total Files processed is $fileCntr \n" exit_func
######################################################################################################################### # # # # CDG Cycle, EOM, and Daily file transfer Automation # Written by Howard Pearl # # Usage: Called by Control-M, can be called manually as needed # ./cdg_transfer.sh BillCycle # where BillCycle = 04th, 06th, 07th, 10th, 13th, 19th, 25th, EOM, Weekly, or Daily # Backward time functionality added 01/14/2011 By Howard Pearl # Usage: Called via command line # ./cdg_transfer.sh BillCycle back # where BillCycle = 04th, 06th, 07th, 10th, 13th, 19th, 25th, EOM, Weekly, or Daily # input required information at prompts # # Updated 03/18/2011 by Matt Blake - Added code to remove "Processed_" prefix in front of # AC0788J files (See Lines 102 - 108). # # Updated 05/10/2011 by Matt Blake - Added code to skip Daily Trigger File generation on # on Saturday. # # Updated 06/06/2011 by Matt Blake/Anand Jain - Added code to remove null chars in AC0766 # weekly file. Added company code 0584 to # Cycle 7 download. # Updated 06/13/2011 by Matt Blake - Added remove null chars to AC0020 and AC0025 weekly files. # Updated 06/14/2011 by Matt Blake - Added remove null chars to AC0020, AC0025 and AC0766 EOM files. # Updated 06/22/2011 by Matt Blake - Removed 0573 from Cycle19. # Updated 06/23/2011 by Matt Blake - Added remove null chars to AC0020, AC0025 and AC0766 Cycle files. # Updated 08/11/2011 by Matt Blake - Added remove null chars to AC0780 Cycle files. # Updated 12/05/2011 by Matt Blake - CO codes 576, 577, &578 discontinued by CDG # thus removed from the list for Cycle 19 # Updated 01/18/2012 by Matt Blake - CO codes 574 and 577 removed from all Cycles and removed # 576 and 578 from Cycle 10 per Kurt Trygg # Updated 02/07/2012 by Matt Blake - Added chmod -R 777 $filedir to end of each cycle function # to ensure cycle folders can be manipulated. For the EOM # function added chmod -R 777 $filepath since $filedir not used. # Updated 04/02/2012 by Matt Blake - Added CASE statement in CycleEOM Function to check if previous # month is between 1 and 9, then concats a "0" to fit correct # folder creation. # Updated 04/11/2012 by Matt Blake - Added CASE statement in the main function to check if jday # is between 1 and 9, then concats a "0" to fit correct # folder creation. # Updated 06/18/2012 by Matt Blake - Added files AC0029 and AC0766 to daily file filter. # Updated 07/05/2012 by Matt Blake - Added files AC0015, AC0027, AC0093 to daily file filter. # # Updated 07/06/2012 by Matt Blake - Added files AC0020 from 0581, 0582, 0583, 0587 along with # AC0025, AC0047 and AC0650 files to weekly file transfer. # Added AC0011 and ASPL.ACKU files to daily file transfer. # Updated 10/30/2012 by Matt Blake - Added file AC0025 to daily file filter. # Updated 11/16/2012 by Matt Blake - Setup script to not create a Trigger File for the Weekly downloads # Updated 11/28/2012 by Matt Blake - Added email for showing what files are being downloaded for the day ################################################################################################################################ # # #Main Variable declarations # # ####################################################################################### HOST='172.24.80.90' #CDG USER NAME AND PASSWORD USER='opdev' PASS='opdev890!' function setdates { #function called if no dates are specified in backwards dating curdate="`date +%Y%m`" curyear="`date +%Y`" curdateday="`date +%Y%m%d`" curmonth="`date +%m`" curday="`date +%d`" prevday="`expr $curday - 1`" curdow="`date +%A`" # Added for Saturday daily trigger file check. } fancydate="`date +%A,` `date +%B ` `date +%d ` `date +%Y`" curdate2="`date +%Y%m`" curyear2="`date +%Y`" curdateday2="`date +%Y%m%d`" curmonth2="`date +%m`" curday2="`date +%d`" curdow2="`date +%A`" # Added for Saturday daily trigger file check. billcycle=$1 lastdir=0 nofiles=" " rtncode=0 filename="" files="" counter=0 finaldir='/fpapps/op/dev/ftproot/ftpdown/' FILE=localftpout ##################################################################################### # #File transfer function for cycle and EOM files. #Weekly and daily transfers finalized 01/14/2011 # ##################################################################################### function transfiles { ftp -inv $HOST <<EOF user $USER $PASS passive cd $remotedir mget * bye EOF } function AC0877aTrans { cd $1 ftp -inv $HOST <<EOF user $USER $PASS passive cd /fpapps/cfr/CDG/Reports echo $curmonth mget *0877A.$curmonth''* bye EOF AC0877jTrans $1 'EOM' $2 } function AC0877jTrans { cd $1 ftp -inv $HOST <<EOF user $USER $PASS passive cd /fpapps/cfr/CDG/Reports mget *0877J.D$3* bye EOF for origfile_name in `ls Processed_*AC0877*.CSV` do # awk command to get the correct file name by removing "Processed" as prefix renamefile_name=`echo $origfile_name | awk -F\_ '{ print $2 }' | sed -e 's/_//'` # move the processed file to regular file name mv $origfile_name $renamefile_name done case $2 in Cycle) CycleTrigger ;; EOM) EOMTrigger ;; *) exit 99 ;; esac } #Added 01/11/2010 to support transferring daily files function dailytransfiles { ftp -inv $HOST <<EOF user $USER $PASS passive cd $1 mget $2 bye EOF #######Code to Replace Special Char in AC0766 and AC0025:Begin####### if [[ $2 = *AC0766*.CSV || $2 = *AC0025*.CSV ]] then tr '\000' '\ '<$2>$2.tmp mv $2.tmp $2 fi #######Code to Replace Special Char in AC0766, AC0020 and AC0025:End####### } function getftpfilenames { ftp -inv $HOST <<EOF user $USER $PASS passive dir $remotedir localftpout dir $remotedir2 localftpout2 bye EOF } #reads filenames and matches on today's date and prefix of "AC" function dailyreadftpfilenames { cat localftpout | while read ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE do if [[ $SEVEN -eq $curday ]] then if [[ $NINE = 'AC'* ]] then echo $remotedir' '$NINE " " >> ftpget fi fi if [[ $SEVEN -eq $prevday ]] then if [[ $NINE = *'AC0025'* ]] #Added because AC0025 daily date is always current day - 1 then echo $remotedir' '$NINE " " >> ftpgetAC25 fi fi done cat ftpgetAC25 >> ftpget ##Append AC0025 File name to ftpget list cat localftpout2 | while read ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE do if [[ $SEVEN -eq $curday ]] then if [[ $NINE = 'AC'* ]] then echo $remotedir2' '$NINE " " >> ftpget fi fi if [[ $SEVEN -eq $prevday ]] then if [[ $NINE = *'ASPL.ACKU'* ]] then echo $remotedir2' '$NINE " " >> ftpgetASPL fi fi done cat ftpgetASPL >> ftpget rm ftpgetAC25 rm ftpgetASPL } #Filters files to only get names contained below function dailyfilefilter { remotedir='/fpapps/cfr/CDG/Reports/0570' remotedir2='/fpapps/cfr/CDG/Reports' for filenames in `cat ftpget` do case $filenames in *ASPL.ACKU*) echo $filenames >> email_body_daily.txt ;; *AC0011*) echo $filenames >> email_body_daily.txt ;; *AC0015*) echo $filenames >> email_body_daily.txt ;; *AC0027*) echo $filenames >> email_body_daily.txt ;; *AC0025*) echo $filenames >> email_body_daily.txt ;; *AC0029*) echo $filenames >> email_body_daily.txt ;; *AC0045*) echo $filenames >> email_body_daily.txt ;; *AC0048*) echo $filenames >> email_body_daily.txt ;; *AC0065*) echo $filenames >> email_body_daily.txt ;; *AC0093*) echo $filenames >> email_body_daily.txt ;; *AC0110*) echo $filenames >> email_body_daily.txt ;; *AC0766*) echo $filenames >> email_body_daily.txt ;; *AC0783*) echo $filenames >> email_body_daily.txt ;; esac done cat email_body_daily.txt | mailx -s "CDG Files Downloading Today, $fancydate" cdgtomdasuccess@fairpoint.com rm email_body_daily.txt for filenames in `cat ftpget` do case $filenames in *ASPL.ACKU*) dailytransfiles $remotedir2 $filenames ;; *AC0011*) dailytransfiles $remotedir2 $filenames ;; *AC0015*) dailytransfiles $remotedir $filenames ;; *AC0027*) dailytransfiles $remotedir $filenames ;; *AC0025*) dailytransfiles $remotedir $filenames ;; *AC0029*) dailytransfiles $remotedir $filenames ;; *AC0045*) dailytransfiles $remotedir $filenames ;; *AC0048*) dailytransfiles $remotedir $filenames ;; *AC0065*) dailytransfiles $remotedir $filenames ;; *AC0093*) dailytransfiles $remotedir $filenames ;; *AC0110*) dailytransfiles $remotedir $filenames ;; *AC0766*) dailytransfiles $remotedir $filenames ;; *AC0783*) dailytransfiles $remotedir $filenames ;; esac done } function getftpfilenamesweekly { ftp -inv $HOST <<EOF user $USER $PASS passive dir $remotedir localftpout dir $remotedir2 localftpout2 dir $remotedir3 localftpout3 dir $remotedir4 localftpout4 dir $remotedir5 localftpout5 bye EOF } function weeklyreadftpfilenames { cat localftpout | while read ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE do if [[ $SEVEN -eq $curday ]] then if [[ $NINE = 'AC'* ]] then echo $remotedir' '$NINE " " >> ftpget fi fi done cat localftpout2 | while read ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE do if [[ $SEVEN -eq $curday ]] then if [[ $NINE = 'AC'* ]] then echo $remotedir2' '$NINE " " >> ftpget fi fi done cat localftpout3 | while read ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE do if [[ $SEVEN -eq $curday ]] then if [[ $NINE = 'AC'* ]] then echo $remotedir3' '$NINE " " >> ftpget fi fi done cat localftpout4 | while read ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE do if [[ $SEVEN -eq $curday ]] then if [[ $NINE = 'AC'* ]] then echo $remotedir4' '$NINE " " >> ftpget fi fi done cat localftpout5 | while read ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE do if [[ $SEVEN -eq $curday ]] then if [[ $NINE = 'AC'* ]] then echo $remotedir5' '$NINE " " >> ftpget fi fi done rm localftpout rm localftpout2 rm localftpout3 rm localftpout4 rm localftpout5 } function weeklyfilefilter { remotedir='/fpapps/cfr/CDG/Reports/0570' remotedir2='/fpapps/cfr/CDG/Reports/0581' remotedir2='/fpapps/cfr/CDG/Reports/0581' remotedir3='/fpapps/cfr/CDG/Reports/0582' remotedir4='/fpapps/cfr/CDG/Reports/0583' remotedir5='/fpapps/cfr/CDG/Reports/0587' for filenames in `cat ftpget` do case $filenames in *C0570*AC0020*) echo $filenames >> email_body_weekly.txt ;; *C0581*AC0020*) echo $filenames >> email_body_weekly.txt ;; *C0582*AC0020*) echo $filenames >> email_body_weekly.txt ;; *C0583*AC0020*) echo $filenames >> email_body_weekly.txt ;; *C0587*AC0020*) echo $filenames >> email_body_weekly.txt ;; *AC0025*) echo $filenames >> email_body_weekly.txt ;; *AC0047*) echo $filenames >> email_body_weekly.txt ;; *AC0650*) echo $filenames >> email_body_weekly.txt ;; esac done cat email_body_weekly.txt | mailx -s "CDG Files Downloading Today, $fancydate" cdgtomdasuccess@fairpoint.com rm email_body_weekly.txt for filenames in `cat ftpget` do case $filenames in *C0570*AC0020*) weeklytransfiles $remotedir $filenames ;; *C0581*AC0020*) weeklytransfiles $remotedir2 $filenames ;; *C0582*AC0020*) weeklytransfiles $remotedir3 $filenames ;; *C0583*AC0020*) weeklytransfiles $remotedir4 $filenames ;; *C0587*AC0020*) weeklytransfiles $remotedir5 $filenames ;; *AC0025*) weeklytransfiles $remotedir $filenames ;; *AC0047*) weeklytransfiles $remotedir $filenames ;; *AC0650*) weeklytransfiles $remotedir $filenames ;; esac done rm ftpget } function weeklytransfiles { ftp -inv $HOST <<EOF user $USER $PASS passive cd $1 mget $2 bye EOF #######Code to Replace Special Char in AC0650, AC0020, AC0047 and AC0025:Begin####### if [[ $2 = *AC0650*.CSV || $2 = *AC0020*.CSV || $2 = *AC0025*.CSV || $2 = *AC0047*.CSV ]] then tr '\000' '\ '<$2>$2.tmp mv $2.tmp $2 fi #######Code to Replace Special Char in AC0650, AC0020, AC0047 and AC0025:End####### } ##################################################################################### # #Remove Empty Cycle Files if no file is present # added 01/06/2011 # ##################################################################################### function checkMissingCycleFiles { cd $1 files=$(ls $1/* 2> /dev/null wc -l) if [ -z $files ] then cd .. rm -r $3'_'$4 directories=$(ls $2/* 2> /dev/null wc -l) if [ -z $directories ] then cd .. rm -r $4 fi cd $finaldir echo "No files in " $5 "\n" >> testfile rtncode=6 fi return $rtncode } ##################################################################################### # #Individual Cycle functions # ##################################################################################### function cycle4 { while [ $counter -lt 6 ] do case $counter in 0) lastdir=0570 ;; 1) lastdir=0571 ;; 2) lastdir=0572 ;; 3) lastdir=0581 ;; 4) lastdir=0582 ;; 5) lastdir=0583 ;; *) exit 99 ;; esac filepath='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle'/'$lastdir'_'$billcycle remotedir='/fpapps/cfr/CDG/Reports/'$lastdir'/'$billcycle'/' filedir='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle if [[ -d $filepath ]] then cd $filepath transfiles for cycfnm in `ls $filepath/**` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir else mkdir -p $filepath cd $filepath transfiles for cycfnm in `ls $filepath/**` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir fi chmod -R 777 $filedir done } function cycle6 { while [ $counter -lt 4 ] do case $counter in 0) lastdir=0572 ;; 1) lastdir=0581 ;; 2) lastdir=0582 ;; 3) lastdir=0583 ;; *) exit 99 ;; esac filepath='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle'/'$lastdir'_'$billcycle remotedir='/fpapps/cfr/CDG/Reports/'$lastdir'/'$billcycle'/' filedir='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle if [[ -d $filepath ]] then cd $filepath transfiles for cycfnm in `ls $filepath/**` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir else mkdir -p $filepath cd $filepath transfiles for cycfnm in `ls $filepath/**` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir fi chmod -R 777 $filedir done } function cycle7 { while [ $counter -lt 5 ] #Updated 06/06/2011 to download company code 0584 do case $counter in 0) lastdir=0570 ;; 1) lastdir=0571 ;; 2) lastdir=0572 ;; 3) lastdir=0573 ;; 4) lastdir=0584 ;; *) exit 99 ;; esac filepath='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle'/'$lastdir'_'$billcycle remotedir='/fpapps/cfr/CDG/Reports/'$lastdir'/'$billcycle'/' filedir='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle if [[ -d $filepath ]] then cd $filepath transfiles for cycfnm in `ls $filepath/**` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir else mkdir -p $filepath cd $filepath transfiles for cycfnm in `ls $filepath/**` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir fi chmod -R 777 $filedir done } function cycle10 { while [ $counter -lt 4 ] do case $counter in 0) lastdir=0570 ;; 1) lastdir=0571 ;; 2) lastdir=0572 ;; 3) lastdir=0581 ;; *) exit 99 ;; esac filepath='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle'/'$lastdir'_'$billcycle remotedir='/fpapps/cfr/CDG/Reports/'$lastdir'/'$billcycle'/' filedir='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle if [[ -d $filepath ]] then cd $filepath transfiles for cycfnm in `ls $filepath/**` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir else mkdir -p $filepath cd $filepath transfiles for cycfnm in `ls $filepath/**` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir fi chmod -R 777 $filedir done } function cycle13 { while [ $counter -lt 4 ] do case $counter in 0) lastdir=0570 ;; 1) lastdir=0571 ;; 2) lastdir=0572 ;; 3) lastdir=0573 ;; *) exit 99 ;; esac filepath='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle'/'$lastdir'_'$billcycle remotedir='/fpapps/cfr/CDG/Reports/'$lastdir'/'$billcycle'/' filedir='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle if [[ -d $filepath ]] then cd $filepath transfiles for cycfnm in `ls $filepath/**` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir else mkdir -p $filepath cd $filepath transfiles for cycfnm in `ls $filepath/**` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir fi chmod -R 777 $filedir done } function cycle19 { while [ $counter -lt 6 ] do case $counter in 0) lastdir=0570 ;; 1) lastdir=0571 ;; 2) lastdir=0572 ;; 3) lastdir=0581 ;; 4) lastdir=0582 ;; 5) lastdir=0583 ;; *) exit 99 ;; esac filepath='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle'/'$lastdir'_'$billcycle remotedir='/fpapps/cfr/CDG/Reports/'$lastdir'/'$billcycle'/' filedir='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle if [[ -d $filepath ]] then cd $filepath transfiles for cycfnm in `ls $filepath/**` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir else mkdir -p $filepath cd $filepath transfiles for cycfnm in `ls $filepath/**` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir fi chmod -R 777 $filedir done } function cycle25 { while [ $counter -lt 10 ] do case $counter in 0) lastdir=0570 ;; 1) lastdir=0571 ;; 2) lastdir=0572 ;; 3) lastdir=0573 ;; 4) lastdir=0576 ;; 5) lastdir=0578 ;; 6) lastdir=0581 ;; 7) lastdir=0582 ;; 8) lastdir=0583 ;; 9) lastdir=0587 ;; *) exit 99 ;; esac filepath='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle'/'$lastdir'_'$billcycle remotedir='/fpapps/cfr/CDG/Reports/'$lastdir'/'$billcycle'/' filedir='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle if [[ -d $filepath ]] then cd $filepath transfiles for cycfnm in `ls $filepath/**` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir else mkdir -p $filepath cd $filepath transfiles for cycfnm in `ls $filepath/**` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir fi chmod -R 777 $filedir done } function cycleDaily { filepath='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/Daily_reports_'$curdate remotedir='/fpapps/cfr/CDG/Reports/0570' remotedir2='/fpapps/cfr/CDG/Reports' if [[ -d $filepath ]] then cd $filepath getftpfilenames dailyreadftpfilenames dailyfilefilter chmod -R 777 $filepath else mkdir -p $filepath cd $filepath getftpfilenames dailyreadftpfilenames dailyfilefilter chmod -R 777 $filepath fi cd $filepath rm ftpget rm localftpout rm localftpout2 } function cycleWeekly { filepath='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/Daily_reports_'$curdate remotedir='/fpapps/cfr/CDG/Reports/0570' remotedir2='/fpapps/cfr/CDG/Reports/0581' remotedir3='/fpapps/cfr/CDG/Reports/0582' remotedir4='/fpapps/cfr/CDG/Reports/0583' remotedir5='/fpapps/cfr/CDG/Reports/0587' if [[ -d $filepath ]] then cd $filepath getftpfilenamesweekly weeklyreadftpfilenames weeklyfilefilter chmod -R 777 $filepath else mkdir -p $filepath cd $filepath getftpfilenamesweekly weeklyreadftpfilenames weeklyfilefilter chmod -R 777 $filepath fi } function cycleEOM { if [[ $curday -le 15 ]] then month=$curmonth year=$curyear lmonth=`expr $month - 1` if test "$lmonth" = "0" then lmonth=12 year=`expr $year - 1` fi #checks concats lmonths between 1 and 9 with a 0 to form correct folders. case $lmonth in "1") lmonth="0"$lmonth;; "2") lmonth="0"$lmonth;; "3") lmonth="0"$lmonth;; "4") lmonth="0"$lmonth;; "5") lmonth="0"$lmonth;; "6") lmonth="0"$lmonth;; "7") lmonth="0"$lmonth;; "8") lmonth="0"$lmonth;; "9") lmonth="0"$lmonth;; *) lmonth=$lmonth;; esac curdate=$year$lmonth curyear=$year curmonth=$lmonth #Used for if EOM cycle runs after the end of the month. I.E. December's transfer running after the 31st. fi while [ $counter -lt 5 ] do case $counter in 0) lastdir=0570 billcycle='EOM_FILES' ;; 1) lastdir=0581 billcycle='UNE_EOM' ;; 2) lastdir=0582 billcycle='582_EOM' ;; 3) lastdir=0583 billcycle='583_EOM' ;; 4) lastdir=0587 billcycle='UNE_L_EOM' ;; *) exit 99 ;; esac filepath='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/EOM_reports_'$curdate'/' remotedir='/fpapps/cfr/CDG/Reports/'$lastdir'/'$billcycle'/' if [[ -d $filepath ]] then cd $filepath transfiles for eomfnm in `ls $filepath/**` ##After files transferred, remove null chars do if [[ $eomfnm = *AC0766*.CSV || $eomfnm = *AC0020*.CSV || $eomfnm = *AC0025*.CSV || $eomfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$eomfnm>$eomfnm.tmp mv $eomfnm.tmp $eomfnm chmod 775 $eomfnm fi done counter=`expr $counter + 1` else mkdir -p $filepath cd $filepath transfiles for eomfnm in `ls $filepath/**` ##After files transferred, remove null chars do if [[ $eomfnm = *AC0766*.CSV || $eomfnm = *AC0020*.CSV || $eomfnm = *AC0025*.CSV || $eomfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$eomfnm>$eomfnm.tmp mv $eomfnm.tmp $eomfnm chmod 775 $eomfnm fi done counter=`expr $counter + 1` files=$(ls $filepath/* 2> /dev/null wc -l) if [ -z $files ] then cd .. rm -r EOM_reports_$curdate echo "No files in " $remotedir "\n" >> testfile rtncode=6 fi fi done cd $filepath chmod -R 777 $filepath } ########################################################################### # # # Trigger Fyle generation # Written: 01/05/2011 by Howard Pearl # For Project Sophia # Updated 01/21/2011, changed trigger file location per Raj by Howard Pearl # # ############################################################################ function CycleTrigger { triggerpath='/fpapps/op/dev/ftproot/ftpdown/TriggerFiles/' if [[ -d $triggerpath ]] then cd $triggerpath touch 'CYCLE.'$curdate''$billcycle'.OK' else mkdir -p $triggerpath cd $triggerpath touch 'CYCLE.'$curdate''$billcycle'.OK' fi } function EOMTrigger { if [[ $curday -le 15 ]] then month=$curmonth2 year=$curyear2 lmonth=`expr $month - 1` if test "$lmonth" = "0" then lmonth=12 year=`expr $year - 1` fi curdate=$year$lmonth curyear=$year #Used for if EOM cycle runs after the end of the month. I.E. December's transfer running after the 31st. fi triggerpath='/fpapps/op/dev/ftproot/ftpdown/TriggerFiles/' if [[ -d $triggerpath ]] then cd $triggerpath touch 'EOM.'$curdate'.OK' else mkdir -p $triggerpath cd $triggerpath touch 'EOM.'$curdate'.OK' fi } #Also used for weekly trigger files Per Raj (01/17/2011) function DailyTrigger { triggerpath='/fpapps/op/dev/ftproot/ftpdown/TriggerFiles/' if [[ $curdow != Saturday ]] #If current day is not Saturday, then the trigger file is created. then if [[ $curdow != Sunday ]] #If current day is not Sunday, then the trigger file is created. then if [[ -d $triggerpath ]] then cd $triggerpath touch 'DAILY.'$curdateday'.OK' else mkdir -p $triggerpath cd $triggerpath touch 'DAILY.'$curdateday'.OK' fi fi fi } ######################################################################### # # Used for reseting dates if run for older date # ######################################################################### function resetdates { read old_day?"Enter Day as Number: " case $old_day in +([0-9]) ) print "valid" ;; * ) echo "invalid entry, please enter a number" exit 99 ;; esac case $old_day in 1) newday=01 ;; 2) newday=02 ;; 3) newday=03 ;; 4) newday=04 ;; 5) newday=05 ;; 6) newday=06 ;; 7) newday=07 ;; 8) newday=08 ;; 9) newday=09 ;; *) newday=$old_day ;; esac read old_month?"Enter Month as Number: " case $old_month in +([0-9]) ) print "valid" ;; * ) echo "invalid entry, please enter a number" exit 99 ;; esac case $old_month in 1) newmonth=01 ;; 2) newmonth=02 ;; 3) newmonth=03 ;; 4) newmonth=04 ;; 5) newmonth=05 ;; 6) newmonth=06 ;; 7) newmonth=07 ;; 8) newmonth=08 ;; 9) newmonth=09 ;; 01) newmonth=01 ;; 02) newmonth=02 ;; 03) newmonth=03 ;; 04) newmonth=04 ;; 05) newmonth=05 ;; 06) newmonth=06 ;; 07) newmonth=07 ;; 08) newmonth=08 ;; 09) newmonth=09 ;; 10) newmonth=10 ;; 11) newmonth=11 ;; 12) newmonth=12 ;; *) echo "There are only 12 months in a year" exit 99 ;; esac read old_year?"Enter Year as four digit number: " case $old_year in +([0-9]) ) print "valid" ;; * ) echo "invalid entry, please enter a number" exit 99 ;; esac len=${#old_year} if [[ $len -eq 4 ]] then newyear=$old_year else echo "Year must be 4 digits" exit 99 fi curdate=$old_year''$old_month curyear=$old_year curdateday=$old_year''$old_month''$old_day curmonth=$old_month curday=$old_day } ######################################################################### # # # # Main Function Begins Here # # # ######################################################################### #determines if past date needs to be specified based on command line inputs *see usage note above* if [[ $2 = 'old' ]] then resetdates else setdates fi case $billcycle in 04th) cycle4 ;; 06th) cycle6 ;; 07th) cycle7 ;; 10th) cycle10 ;; 13th) cycle13 ;; 19th) cycle19 ;; 25th) cycle25 ;; Daily) cycleDaily ;; EOM) cycleEOM ;; Weekly) cycleWeekly ;; *) exit 99 ;; esac #if return code is 6, no files available for given cycle. See system output in Control-M for details as to which files are missing if [[ $rtncode -eq 6 ]] then cd $finaldir cat testfile rm -r testfile exit 6 else #Minus one day for 877J transfer filepath='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle'/' eomfilepath='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/' day=$curday2 jmonth=$curmonth2 jday=`expr $day - 1` if [[ $jday -eq 0 ]] then jmonth=`expr $jmonth - 1` if [[ $jmonth -eq 0 ]] then jmonth=12 fi case $jmonth in 1) jday=31 ;; 2) jday=28 ;; 3) jday=31 ;; 4) jday=30 ;; 5) jday=31 ;; 6) jday=30 ;; 7) jday=31 ;; 8) jday=31 ;; 9) jday=30 ;; 10) jday=31 ;; 11) jday=30 ;; 12) jday=31 ;; *) exit 99 ;; esac fi #checks and concats jday between 1 and 9 with a 0 to form correct folders. case $jday in "1") jday="0"$jday;; "2") jday="0"$jday;; "3") jday="0"$jday;; "4") jday="0"$jday;; "5") jday="0"$jday;; "6") jday="0"$jday;; "7") jday="0"$jday;; "8") jday="0"$jday;; "9") jday="0"$jday;; *) jday=$jday;; esac acjdate=$jmonth''$jday #runs 877j trans for cycle files, and 877j and 877a files for monthly files #Weekly trigger information added 01/17/2011 by Howard Pearl echo $billcycle case $billcycle in 04th) AC0877jTrans $filepath 'Cycle' $acjdate ;; 06th) AC0877jTrans $filepath 'Cycle' $acjdate ;; 07th) AC0877jTrans $filepath 'Cycle' $acjdate ;; 10th) AC0877jTrans $filepath 'Cycle' $acjdate ;; 13th) AC0877jTrans $filepath 'Cycle' $acjdate ;; 19th) AC0877jTrans $filepath 'Cycle' $acjdate ;; 25th) AC0877jTrans $filepath 'Cycle' $acjdate ;; Daily) DailyTrigger ;; Weekly) DailyTrigger ;; EOM) AC0877aTrans $eomfilepath $acjdate ;; *) exit 99 ;; esac exit 0 fi
######################################################################################################################### # # # # CDG Cycle, EOM, and Daily file transfer Automation # Written by Howard Pearl # # Usage: Called by Control-M, can be called manually as needed # ./cdg_transfer.sh BillCycle # where BillCycle = 04th, 06th, 07th, 10th, 13th, 19th, 25th, EOM, Weekly, or Daily # Backward time functionality added 01/14/2011 By Howard Pearl # Usage: Called via command line # ./cdg_transfer.sh BillCycle back # where BillCycle = 04th, 06th, 07th, 10th, 13th, 19th, 25th, EOM, Weekly, or Daily # input required information at prompts # # Updated 03/18/2011 by Matt Blake - Added code to remove "Processed_" prefix in front of # AC0788J files (See Lines 102 - 108). # # Updated 05/10/2011 by Matt Blake - Added code to skip Daily Trigger File generation on # on Saturday. # # Updated 06/06/2011 by Matt Blake/Anand Jain - Added code to remove null chars in AC0766 # weekly file. Added company code 0584 to # Cycle 7 download. # Updated 06/13/2011 by Matt Blake - Added remove null chars to AC0020 and AC0025 weekly files. # Updated 06/14/2011 by Matt Blake - Added remove null chars to AC0020, AC0025 and AC0766 EOM files. # Updated 06/22/2011 by Matt Blake - Removed 0573 from Cycle19. # Updated 06/23/2011 by Matt Blake - Added remove null chars to AC0020, AC0025 and AC0766 Cycle files. # Updated 08/11/2011 by Matt Blake - Added remove null chars to AC0780 Cycle files. # Updated 12/05/2011 by Matt Blake - CO codes 576, 577, &578 discontinued by CDG # thus removed from the list for Cycle 19 # Updated 01/18/2012 by Matt Blake - CO codes 574 and 577 removed from all Cycles and removed # 576 and 578 from Cycle 10 per Kurt Trygg # Updated 02/07/2012 by Matt Blake - Added chmod -R 777 $filedir to end of each cycle function # to ensure cycle folders can be manipulated. For the EOM # function added chmod -R 777 $filepath since $filedir not used. # Updated 04/02/2012 by Matt Blake - Added CASE statement in CycleEOM Function to check if previous # month is between 1 and 9, then concats a "0" to fit correct # folder creation. # Updated 04/11/2012 by Matt Blake - Added CASE statement in the main function to check if jday # is between 1 and 9, then concats a "0" to fit correct # folder creation. # Updated 06/18/2012 by Matt Blake - Added files AC0029 and AC0766 to daily file filter. # Updated 07/05/2012 by Matt Blake - Added files AC0015, AC0027, AC0093 to daily file filter. # # Updated 07/06/2012 by Matt Blake - Added files AC0020 from 0581, 0582, 0583, 0587 along with # AC0025, AC0047 and AC0650 files to weekly file transfer. # Added AC0011 and ASPL.ACKU files to daily file transfer. # Updated 10/30/2012 by Matt Blake - Added file AC0025 to daily file filter. # Updated 11/16/2012 by Matt Blake - Setup script to not create a Trigger File for the Weekly downloads # Updated 11/28/2012 by Matt Blake - Added email for showing what files are being downloaded for the day ################################################################################################################################ # # #Main Variable declarations # # ####################################################################################### HOST='172.24.80.90' #CDG USER NAME AND PASSWORD USER='opdev' PASS='opdev890!' function setdates { #function called if no dates are specified in backwards dating curdate="`date +%Y%m`" curyear="`date +%Y`" curdateday="`date +%Y%m%d`" curmonth="`date +%m`" curday="`date +%d`" prevday="`expr $curday - 1`" curdow="`date +%A`" # Added for Saturday daily trigger file check. } fancydate="`date +%A,` `date +%B ` `date +%d ` `date +%Y`" curdate2="`date +%Y%m`" curyear2="`date +%Y`" curdateday2="`date +%Y%m%d`" curmonth2="`date +%m`" curday2="`date +%d`" curdow2="`date +%A`" # Added for Saturday daily trigger file check. billcycle=$1 lastdir=0 nofiles=" " rtncode=0 filename="" files="" counter=0 finaldir='/fpapps/op/dev/ftproot/ftpdown/' FILE=localftpout ##################################################################################### # #File transfer function for cycle and EOM files. #Weekly and daily transfers finalized 01/14/2011 # ##################################################################################### function transfiles { ftp -inv $HOST <<EOF user $USER $PASS passive cd $remotedir mget * bye EOF } function AC0877aTrans { cd $1 ftp -inv $HOST <<EOF user $USER $PASS passive cd /fpapps/cfr/CDG/Reports echo $curmonth mget *0877A.$curmonth''* bye EOF AC0877jTrans $1 'EOM' $2 } function AC0877jTrans { cd $1 ftp -inv $HOST <<EOF user $USER $PASS passive cd /fpapps/cfr/CDG/Reports mget *0877J.D$3* bye EOF for origfile_name in `ls Processed_*AC0877*` do # awk command to get the correct file name by removing "Processed" as prefix renamefile_name=`echo $origfile_name | awk -F\_ '{ print $2 }' | sed -e 's/_//'` # move the processed file to regular file name mv $origfile_name $finaldir/$renamefile_name done case $2 in Cycle) CycleTrigger ;; EOM) EOMTrigger ;; *) exit 99 ;; esac } #Added 01/11/2010 to support transferring daily files function dailytransfiles { ftp -inv $HOST <<EOF user $USER $PASS passive cd $1 mget $2 bye EOF #######Code to Replace Special Char in AC0766 and AC0025:Begin####### if [[ $2 = *AC0766*.CSV || $2 = *AC0025*.CSV ]] then tr '\000' '\ '<$2>$2.tmp mv $2.tmp $finaldir/$2 fi #######Code to Replace Special Char in AC0766, AC0020 and AC0025:End####### } function getftpfilenames { ftp -inv $HOST <<EOF user $USER $PASS passive dir $remotedir localftpout dir $remotedir2 localftpout2 bye EOF } #reads filenames and matches on today's date and prefix of "AC" function dailyreadftpfilenames { cat localftpout | while read ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE do if [[ $SEVEN -eq $curday ]] then if [[ $NINE = 'AC'* ]] then echo $remotedir' '$NINE " " >> ftpget fi fi if [[ $SEVEN -eq $prevday ]] then if [[ $NINE = *'AC0025'* ]] #Added because AC0025 daily date is always current day - 1 then echo $remotedir' '$NINE " " >> ftpgetAC25 fi fi done cat ftpgetAC25 >> ftpget ##Append AC0025 File name to ftpget list cat localftpout2 | while read ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE do if [[ $SEVEN -eq $curday ]] then if [[ $NINE = 'AC'* ]] then echo $remotedir2' '$NINE " " >> ftpget fi fi if [[ $SEVEN -eq $prevday ]] then if [[ $NINE = *'ASPL.ACKU'* ]] then echo $remotedir2' '$NINE " " >> ftpgetASPL fi fi done cat ftpgetASPL >> ftpget rm ftpgetAC25 rm ftpgetASPL } #Filters files to only get names contained below function dailyfilefilter { remotedir='/fpapps/cfr/CDG/Reports/0570' remotedir2='/fpapps/cfr/CDG/Reports' for filenames in `cat ftpget` do case $filenames in *ASPL.ACKU*) echo $filenames >> email_body_daily.txt ;; *AC0011*) echo $filenames >> email_body_daily.txt ;; *AC0015*) echo $filenames >> email_body_daily.txt ;; *AC0027*) echo $filenames >> email_body_daily.txt ;; *AC0025*) echo $filenames >> email_body_daily.txt ;; *AC0029*) echo $filenames >> email_body_daily.txt ;; *AC0045*) echo $filenames >> email_body_daily.txt ;; *AC0048*) echo $filenames >> email_body_daily.txt ;; *AC0065*) echo $filenames >> email_body_daily.txt ;; *AC0093*) echo $filenames >> email_body_daily.txt ;; *AC0110*) echo $filenames >> email_body_daily.txt ;; *AC0766*) echo $filenames >> email_body_daily.txt ;; *AC0783*) echo $filenames >> email_body_daily.txt ;; esac done cat email_body_daily.txt | mailx -s "CDG Files Downloading Today, $fancydate" cdgtomdasuccess@fairpoint.com rm email_body_daily.txt for filenames in `cat ftpget` do case $filenames in *ASPL.ACKU*) dailytransfiles $remotedir2 $filenames ;; *AC0011*) dailytransfiles $remotedir2 $filenames ;; *AC0015*) dailytransfiles $remotedir $filenames ;; *AC0027*) dailytransfiles $remotedir $filenames ;; *AC0025*) dailytransfiles $remotedir $filenames ;; *AC0029*) dailytransfiles $remotedir $filenames ;; *AC0045*) dailytransfiles $remotedir $filenames ;; *AC0048*) dailytransfiles $remotedir $filenames ;; *AC0065*) dailytransfiles $remotedir $filenames ;; *AC0093*) dailytransfiles $remotedir $filenames ;; *AC0110*) dailytransfiles $remotedir $filenames ;; *AC0766*) dailytransfiles $remotedir $filenames ;; *AC0783*) dailytransfiles $remotedir $filenames ;; esac done } function getftpfilenamesweekly { ftp -inv $HOST <<EOF user $USER $PASS passive dir $remotedir localftpout dir $remotedir2 localftpout2 dir $remotedir3 localftpout3 dir $remotedir4 localftpout4 dir $remotedir5 localftpout5 bye EOF } function weeklyreadftpfilenames { cat localftpout | while read ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE do if [[ $SEVEN -eq $curday ]] then if [[ $NINE = 'AC'* ]] then echo $remotedir' '$NINE " " >> ftpget fi fi done cat localftpout2 | while read ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE do if [[ $SEVEN -eq $curday ]] then if [[ $NINE = 'AC'* ]] then echo $remotedir2' '$NINE " " >> ftpget fi fi done cat localftpout3 | while read ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE do if [[ $SEVEN -eq $curday ]] then if [[ $NINE = 'AC'* ]] then echo $remotedir3' '$NINE " " >> ftpget fi fi done cat localftpout4 | while read ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE do if [[ $SEVEN -eq $curday ]] then if [[ $NINE = 'AC'* ]] then echo $remotedir4' '$NINE " " >> ftpget fi fi done cat localftpout5 | while read ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE do if [[ $SEVEN -eq $curday ]] then if [[ $NINE = 'AC'* ]] then echo $remotedir5' '$NINE " " >> ftpget fi fi done rm localftpout rm localftpout2 rm localftpout3 rm localftpout4 rm localftpout5 } function weeklyfilefilter { remotedir='/fpapps/cfr/CDG/Reports/0570' remotedir2='/fpapps/cfr/CDG/Reports/0581' remotedir2='/fpapps/cfr/CDG/Reports/0581' remotedir3='/fpapps/cfr/CDG/Reports/0582' remotedir4='/fpapps/cfr/CDG/Reports/0583' remotedir5='/fpapps/cfr/CDG/Reports/0587' for filenames in `cat ftpget` do case $filenames in *C0570*AC0020*) echo $filenames >> email_body_weekly.txt ;; *C0581*AC0020*) echo $filenames >> email_body_weekly.txt ;; *C0582*AC0020*) echo $filenames >> email_body_weekly.txt ;; *C0583*AC0020*) echo $filenames >> email_body_weekly.txt ;; *C0587*AC0020*) echo $filenames >> email_body_weekly.txt ;; *AC0025*) echo $filenames >> email_body_weekly.txt ;; *AC0047*) echo $filenames >> email_body_weekly.txt ;; *AC0650*) echo $filenames >> email_body_weekly.txt ;; esac done cat email_body_weekly.txt | mailx -s "CDG Files Downloading Today, $fancydate" cdgtomdasuccess@fairpoint.com rm email_body_weekly.txt for filenames in `cat ftpget` do case $filenames in *C0570*AC0020*) weeklytransfiles $remotedir $filenames ;; *C0581*AC0020*) weeklytransfiles $remotedir2 $filenames ;; *C0582*AC0020*) weeklytransfiles $remotedir3 $filenames ;; *C0583*AC0020*) weeklytransfiles $remotedir4 $filenames ;; *C0587*AC0020*) weeklytransfiles $remotedir5 $filenames ;; *AC0025*) weeklytransfiles $remotedir $filenames ;; *AC0047*) weeklytransfiles $remotedir $filenames ;; *AC0650*) weeklytransfiles $remotedir $filenames ;; esac done rm ftpget } function weeklytransfiles { ftp -inv $HOST <<EOF user $USER $PASS passive cd $1 mget $2 bye EOF #######Code to Replace Special Char in AC0650, AC0020, AC0047 and AC0025:Begin####### if [[ $2 = *AC0650*.CSV || $2 = *AC0020*.CSV || $2 = *AC0025*.CSV || $2 = *AC0047*.CSV ]] then tr '\000' '\ '<$2>$2.tmp mv $2.tmp $finaldir/$2 fi #######Code to Replace Special Char in AC0650, AC0020, AC0047 and AC0025:End####### } ##################################################################################### # #Remove Empty Cycle Files if no file is present # added 01/06/2011 # ##################################################################################### function checkMissingCycleFiles { cd $1 files=$(ls $1/* 2> /dev/null wc -l) if [ -z $files ] then cd .. rm -r $3'_'$4 directories=$(ls $2/* 2> /dev/null wc -l) if [ -z $directories ] then cd .. rm -r $4 fi cd $finaldir echo "No files in " $5 "\n" >> testfile rtncode=6 fi return $rtncode } ##################################################################################### # #Individual Cycle functions # ##################################################################################### function cycle4 { while [ $counter -lt 6 ] do case $counter in 0) lastdir=0570 ;; 1) lastdir=0571 ;; 2) lastdir=0572 ;; 3) lastdir=0581 ;; 4) lastdir=0582 ;; 5) lastdir=0583 ;; *) exit 99 ;; esac filepath='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle'/'$lastdir'_'$billcycle remotedir='/fpapps/cfr/CDG/Reports/'$lastdir'/'$billcycle'/' filedir='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle if [[ -d $filepath ]] then cd $filepath transfiles for cycfnm in `ls $filepath/AC3.C*.AC0*.D*.T*.CSV*` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $finaldir/$cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir else mkdir -p $filepath cd $filepath transfiles for cycfnm in `ls $filepath/AC3.C*.AC0*.D*.T*.CSV*` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $finaldir/$cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir fi chmod -R 777 $filedir done } function cycle6 { while [ $counter -lt 4 ] do case $counter in 0) lastdir=0572 ;; 1) lastdir=0581 ;; 2) lastdir=0582 ;; 3) lastdir=0583 ;; *) exit 99 ;; esac filepath='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle'/'$lastdir'_'$billcycle remotedir='/fpapps/cfr/CDG/Reports/'$lastdir'/'$billcycle'/' filedir='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle if [[ -d $filepath ]] then cd $filepath transfiles for cycfnm in `ls $filepath/AC3.C*.AC0*.D*.T*.CSV*` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $finaldir/$cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir else mkdir -p $filepath cd $filepath transfiles for cycfnm in `ls $filepath/AC3.C*.AC0*.D*.T*.CSV*` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $finaldir/$cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir fi chmod -R 777 $filedir done } function cycle7 { while [ $counter -lt 5 ] #Updated 06/06/2011 to download company code 0584 do case $counter in 0) lastdir=0570 ;; 1) lastdir=0571 ;; 2) lastdir=0572 ;; 3) lastdir=0573 ;; 4) lastdir=0584 ;; *) exit 99 ;; esac filepath='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle'/'$lastdir'_'$billcycle remotedir='/fpapps/cfr/CDG/Reports/'$lastdir'/'$billcycle'/' filedir='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle if [[ -d $filepath ]] then cd $filepath transfiles for cycfnm in `ls $filepath/AC3.C*.AC0*.D*.T*.CSV*` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $finaldir/$cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir else mkdir -p $filepath cd $filepath transfiles for cycfnm in `ls $filepath/AC3.C*.AC0*.D*.T*.CSV*` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $finaldir/$cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir fi chmod -R 777 $filedir done } function cycle10 { while [ $counter -lt 4 ] do case $counter in 0) lastdir=0570 ;; 1) lastdir=0571 ;; 2) lastdir=0572 ;; 3) lastdir=0581 ;; *) exit 99 ;; esac filepath='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle'/'$lastdir'_'$billcycle remotedir='/fpapps/cfr/CDG/Reports/'$lastdir'/'$billcycle'/' filedir='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle if [[ -d $filepath ]] then cd $filepath transfiles for cycfnm in `ls $filepath/AC3.C*.AC0*.D*.T*.CSV*` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $finaldir/$cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir else mkdir -p $filepath cd $filepath transfiles for cycfnm in `ls $filepath/AC3.C*.AC0*.D*.T*.CSV*` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $finaldir/$cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir fi chmod -R 777 $filedir done } function cycle13 { while [ $counter -lt 4 ] do case $counter in 0) lastdir=0570 ;; 1) lastdir=0571 ;; 2) lastdir=0572 ;; 3) lastdir=0573 ;; *) exit 99 ;; esac filepath='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle'/'$lastdir'_'$billcycle remotedir='/fpapps/cfr/CDG/Reports/'$lastdir'/'$billcycle'/' filedir='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle if [[ -d $filepath ]] then cd $filepath transfiles for cycfnm in `ls $filepath/AC3.C*.AC0*.D*.T*.CSV*` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $finaldir/$cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir else mkdir -p $filepath cd $filepath transfiles for cycfnm in `ls $filepath/AC3.C*.AC0*.D*.T*.CSV*` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $finaldir/$cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir fi chmod -R 777 $filedir done } function cycle19 { while [ $counter -lt 6 ] do case $counter in 0) lastdir=0570 ;; 1) lastdir=0571 ;; 2) lastdir=0572 ;; 3) lastdir=0581 ;; 4) lastdir=0582 ;; 5) lastdir=0583 ;; *) exit 99 ;; esac filepath='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle'/'$lastdir'_'$billcycle remotedir='/fpapps/cfr/CDG/Reports/'$lastdir'/'$billcycle'/' filedir='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle if [[ -d $filepath ]] then cd $filepath transfiles for cycfnm in `ls $filepath/AC3.C*.AC0*.D*.T*.CSV*` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $finaldir/$cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir else mkdir -p $filepath cd $filepath transfiles for cycfnm in `ls $filepath/AC3.C*.AC0*.D*.T*.CSV*` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $finaldir/$cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir fi chmod -R 777 $filedir done } function cycle25 { while [ $counter -lt 10 ] do case $counter in 0) lastdir=0570 ;; 1) lastdir=0571 ;; 2) lastdir=0572 ;; 3) lastdir=0573 ;; 4) lastdir=0576 ;; 5) lastdir=0578 ;; 6) lastdir=0581 ;; 7) lastdir=0582 ;; 8) lastdir=0583 ;; 9) lastdir=0587 ;; *) exit 99 ;; esac filepath='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle'/'$lastdir'_'$billcycle remotedir='/fpapps/cfr/CDG/Reports/'$lastdir'/'$billcycle'/' filedir='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle if [[ -d $filepath ]] then cd $filepath transfiles for cycfnm in `ls $filepath/AC3.C*.AC0*.D*.T*.CSV*` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $finaldir/$cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir else mkdir -p $filepath cd $filepath transfiles for cycfnm in `ls $filepath/AC3.C*.AC0*.D*.T*.CSV*` ##After files transferred, remove null chars do if [[ $cycfnm = *AC0766*.CSV || $cycfnm = *AC0020*.CSV || $cycfnm = *AC0025*.CSV || $cycfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$cycfnm>$cycfnm.tmp mv $cycfnm.tmp $finaldir/$cycfnm chmod 775 $cycfnm fi done counter=`expr $counter + 1` checkMissingCycleFiles $filepath $filedir $lastdir $billcycle $remotedir fi chmod -R 777 $filedir done } function cycleDaily { filepath='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/Daily_reports_'$curdate remotedir='/fpapps/cfr/CDG/Reports/0570' remotedir2='/fpapps/cfr/CDG/Reports' if [[ -d $filepath ]] then cd $filepath getftpfilenames dailyreadftpfilenames dailyfilefilter chmod -R 777 $filepath else mkdir -p $filepath cd $filepath getftpfilenames dailyreadftpfilenames dailyfilefilter chmod -R 777 $filepath fi cd $filepath rm ftpget rm localftpout rm localftpout2 } function cycleWeekly { filepath='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/Daily_reports_'$curdate remotedir='/fpapps/cfr/CDG/Reports/0570' remotedir2='/fpapps/cfr/CDG/Reports/0581' remotedir3='/fpapps/cfr/CDG/Reports/0582' remotedir4='/fpapps/cfr/CDG/Reports/0583' remotedir5='/fpapps/cfr/CDG/Reports/0587' if [[ -d $filepath ]] then cd $filepath getftpfilenamesweekly weeklyreadftpfilenames weeklyfilefilter chmod -R 777 $filepath else mkdir -p $filepath cd $filepath getftpfilenamesweekly weeklyreadftpfilenames weeklyfilefilter chmod -R 777 $filepath fi } function cycleEOM { if [[ $curday -le 15 ]] then month=$curmonth year=$curyear lmonth=`expr $month - 1` if test "$lmonth" = "0" then lmonth=12 year=`expr $year - 1` fi #checks concats lmonths between 1 and 9 with a 0 to form correct folders. case $lmonth in "1") lmonth="0"$lmonth;; "2") lmonth="0"$lmonth;; "3") lmonth="0"$lmonth;; "4") lmonth="0"$lmonth;; "5") lmonth="0"$lmonth;; "6") lmonth="0"$lmonth;; "7") lmonth="0"$lmonth;; "8") lmonth="0"$lmonth;; "9") lmonth="0"$lmonth;; *) lmonth=$lmonth;; esac curdate=$year$lmonth curyear=$year curmonth=$lmonth #Used for if EOM cycle runs after the end of the month. I.E. December's transfer running after the 31st. fi while [ $counter -lt 5 ] do case $counter in 0) lastdir=0570 billcycle='EOM_FILES' ;; 1) lastdir=0581 billcycle='UNE_EOM' ;; 2) lastdir=0582 billcycle='582_EOM' ;; 3) lastdir=0583 billcycle='583_EOM' ;; 4) lastdir=0587 billcycle='UNE_L_EOM' ;; *) exit 99 ;; esac filepath='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/EOM_reports_'$curdate'/' remotedir='/fpapps/cfr/CDG/Reports/'$lastdir'/'$billcycle'/' if [[ -d $filepath ]] then cd $filepath transfiles for eomfnm in `ls $filepath/AC3.C*.AC0*.D*.T*.CSV*` ##After files transferred, remove null chars do if [[ $eomfnm = *AC0766*.CSV || $eomfnm = *AC0020*.CSV || $eomfnm = *AC0025*.CSV || $eomfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$eomfnm>$eomfnm.tmp mv $eomfnm.tmp $finaldir/$eomfnm chmod 775 $eomfnm fi done counter=`expr $counter + 1` else mkdir -p $filepath cd $filepath transfiles for eomfnm in `ls $filepath/AC3.C*.AC0*.D*.T*.CSV*` ##After files transferred, remove null chars do if [[ $eomfnm = *AC0766*.CSV || $eomfnm = *AC0020*.CSV || $eomfnm = *AC0025*.CSV || $eomfnm = *AC0780*.CSV ]] then tr '\000' '\ ' <$eomfnm>$eomfnm.tmp mv $eomfnm.tmp $finaldir/$eomfnm chmod 775 $eomfnm fi done counter=`expr $counter + 1` files=$(ls $filepath/* 2> /dev/null wc -l) if [ -z $files ] then cd .. rm -r EOM_reports_$curdate echo "No files in " $remotedir "\n" >> testfile rtncode=6 fi fi done cd $filepath chmod -R 777 $filepath } ########################################################################### # # # Trigger Fyle generation # Written: 01/05/2011 by Howard Pearl # For Project Sophia # Updated 01/21/2011, changed trigger file location per Raj by Howard Pearl # # ############################################################################ function CycleTrigger { triggerpath='/fpapps/op/dev/ftproot/ftpdown/TriggerFiles/' if [[ -d $triggerpath ]] then cd $triggerpath touch 'CYCLE.'$curdate''$billcycle'.OK' else mkdir -p $triggerpath cd $triggerpath touch 'CYCLE.'$curdate''$billcycle'.OK' fi } function EOMTrigger { if [[ $curday -le 15 ]] then month=$curmonth2 year=$curyear2 lmonth=`expr $month - 1` if test "$lmonth" = "0" then lmonth=12 year=`expr $year - 1` fi curdate=$year$lmonth curyear=$year #Used for if EOM cycle runs after the end of the month. I.E. December's transfer running after the 31st. fi triggerpath='/fpapps/op/dev/ftproot/ftpdown/TriggerFiles/' if [[ -d $triggerpath ]] then cd $triggerpath touch 'EOM.'$curdate'.OK' else mkdir -p $triggerpath cd $triggerpath touch 'EOM.'$curdate'.OK' fi } #Also used for weekly trigger files Per Raj (01/17/2011) function DailyTrigger { triggerpath='/fpapps/op/dev/ftproot/ftpdown/TriggerFiles/' if [[ $curdow != Saturday ]] #If current day is not Saturday, then the trigger file is created. then if [[ $curdow != Sunday ]] #If current day is not Sunday, then the trigger file is created. then if [[ -d $triggerpath ]] then cd $triggerpath touch 'DAILY.'$curdateday'.OK' else mkdir -p $triggerpath cd $triggerpath touch 'DAILY.'$curdateday'.OK' fi fi fi } ######################################################################### # # Used for reseting dates if run for older date # ######################################################################### function resetdates { read old_day?"Enter Day as Number: " case $old_day in +([0-9]) ) print "valid" ;; * ) echo "invalid entry, please enter a number" exit 99 ;; esac case $old_day in 1) newday=01 ;; 2) newday=02 ;; 3) newday=03 ;; 4) newday=04 ;; 5) newday=05 ;; 6) newday=06 ;; 7) newday=07 ;; 8) newday=08 ;; 9) newday=09 ;; *) newday=$old_day ;; esac read old_month?"Enter Month as Number: " case $old_month in +([0-9]) ) print "valid" ;; * ) echo "invalid entry, please enter a number" exit 99 ;; esac case $old_month in 1) newmonth=01 ;; 2) newmonth=02 ;; 3) newmonth=03 ;; 4) newmonth=04 ;; 5) newmonth=05 ;; 6) newmonth=06 ;; 7) newmonth=07 ;; 8) newmonth=08 ;; 9) newmonth=09 ;; 01) newmonth=01 ;; 02) newmonth=02 ;; 03) newmonth=03 ;; 04) newmonth=04 ;; 05) newmonth=05 ;; 06) newmonth=06 ;; 07) newmonth=07 ;; 08) newmonth=08 ;; 09) newmonth=09 ;; 10) newmonth=10 ;; 11) newmonth=11 ;; 12) newmonth=12 ;; *) echo "There are only 12 months in a year" exit 99 ;; esac read old_year?"Enter Year as four digit number: " case $old_year in +([0-9]) ) print "valid" ;; * ) echo "invalid entry, please enter a number" exit 99 ;; esac len=${#old_year} if [[ $len -eq 4 ]] then newyear=$old_year else echo "Year must be 4 digits" exit 99 fi curdate=$old_year''$old_month curyear=$old_year curdateday=$old_year''$old_month''$old_day curmonth=$old_month curday=$old_day } ######################################################################### # # # # Main Function Begins Here # # # ######################################################################### #determines if past date needs to be specified based on command line inputs *see usage note above* if [[ $2 = 'old' ]] then resetdates else setdates fi case $billcycle in 04th) cycle4 ;; 06th) cycle6 ;; 07th) cycle7 ;; 10th) cycle10 ;; 13th) cycle13 ;; 19th) cycle19 ;; 25th) cycle25 ;; Daily) cycleDaily ;; EOM) cycleEOM ;; Weekly) cycleWeekly ;; *) exit 99 ;; esac #if return code is 6, no files available for given cycle. See system output in Control-M for details as to which files are missing if [[ $rtncode -eq 6 ]] then cd $finaldir cat testfile rm -r testfile exit 6 else #Minus one day for 877J transfer filepath='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/'$billcycle'/' eomfilepath='/fpapps/op/dev/ftproot/ftpdown/'$curyear'_Billing/'$curdate'_Final/' day=$curday2 jmonth=$curmonth2 jday=`expr $day - 1` if [[ $jday -eq 0 ]] then jmonth=`expr $jmonth - 1` if [[ $jmonth -eq 0 ]] then jmonth=12 fi case $jmonth in 1) jday=31 ;; 2) jday=28 ;; 3) jday=31 ;; 4) jday=30 ;; 5) jday=31 ;; 6) jday=30 ;; 7) jday=31 ;; 8) jday=31 ;; 9) jday=30 ;; 10) jday=31 ;; 11) jday=30 ;; 12) jday=31 ;; *) exit 99 ;; esac fi #checks and concats jday between 1 and 9 with a 0 to form correct folders. case $jday in "1") jday="0"$jday;; "2") jday="0"$jday;; "3") jday="0"$jday;; "4") jday="0"$jday;; "5") jday="0"$jday;; "6") jday="0"$jday;; "7") jday="0"$jday;; "8") jday="0"$jday;; "9") jday="0"$jday;; *) jday=$jday;; esac acjdate=$jmonth''$jday #runs 877j trans for cycle files, and 877j and 877a files for monthly files #Weekly trigger information added 01/17/2011 by Howard Pearl echo $billcycle case $billcycle in 04th) AC0877jTrans $filepath 'Cycle' $acjdate ;; 06th) AC0877jTrans $filepath 'Cycle' $acjdate ;; 07th) AC0877jTrans $filepath 'Cycle' $acjdate ;; 10th) AC0877jTrans $filepath 'Cycle' $acjdate ;; 13th) AC0877jTrans $filepath 'Cycle' $acjdate ;; 19th) AC0877jTrans $filepath 'Cycle' $acjdate ;; 25th) AC0877jTrans $filepath 'Cycle' $acjdate ;; Daily) DailyTrigger ;; Weekly) DailyTrigger ;; EOM) AC0877aTrans $eomfilepath $acjdate ;; *) exit 99 ;; esac exit 0 fi
|
|