#Define log params logPath=/app/log/public/ora_load_data/${sysDate} logFile=${logPath}/${ctlName}.log logTemp=${logPath}/${ctlName}.tmp #Define temp log file for sqlldr, show in moia badFile=${logPath}/${ctlName}.bad
#Log function Log() { createTime=`date +"%Y-%m-%d %H:%M:%S"` echo"[${createTime}] $*" |tee -a ${logFile} 2>/dev/null }
#CheckDir function CheckDir() { if [ ! -d $1 ]; then mkdir_log=` mkdir -p -m 775 $1 ` if [ $? -ne 0 ]; then Log "[Error] [$1] create failed, dir not exist, please check..." exit 255 fi fi } CheckDir "${logPath}"
################### Main program ################### #check the parameter if [ $# -ne 5 ]; then Log "[Error] Please input the right parameter ..." Log "[Error] Eg:sh ora_load_data.sh oraSid user passwd /app/file/userinfo.ctl /app/file/20200630" exit 255 fi
#Check ctlFile if [ ! -f ${ctlFile} ];then Log "[Error] ${ctlFile} not exist, please check..." exit 255 fi
#Check dataPath if [ ! -d ${dataPath} ];then Log "[Error] ${dataPath} not exist, please check..." exit 255 fi
cd${dataPath} if [ $? -ne 0 ];then Log "[Error] Failed to change path ${dataPath}..." exit 255 fi
#Check datafile datafile=`cat${ctlFile}| grep infile |awk -F \' '{print$2}'` if [ ! -f ${datafile} ];then Log "[Error] ${datafile} not exists,please check..." exit 11 fi