#!/bin/sh BASE_PATH=`dirname $0` . ${BASE_PATH}/batchenv.sh ######################################<+>####################################### # File: # Project: # Description: # Language: # Date: # Author: # Update: ######################################<+>####################################### error_message() { echo ${LOG_STR} LOG_STR=`log_output C "" ` echo ${LOG_STR} USAGE="USAGE: ./${SHELL_BASENAME} -s[SCHEMA] -p[PASSWORD]" USAGE_EXP="\\t-s[SCHEMA]・・・・・・スキーマ名\\n\ \\t-p[PASSWORD]・・・・・パスワード" LOG_STR=`log_output C "${USAGE}"` echo -e ${LOG_STR} echo -e ${USAGE_EXP} } # メイン関数 main() { LOG_STR=`log_output I "開始 : DB展開(${SHELL_BASENAME})" ` echo ${LOG_STR} # 引数設定内容 LOG_STR=`log_output I "SCHEMA:${SCHEMA}"` echo ${LOG_STR} LOG_STR=`log_output I "PASSWORD:${PASSWORD_MASKING}"` echo ${LOG_STR} # パラメータの生成 TMP_CTRL_FILE=${LOG_DIR}/${SHELL_BASENAME}.$$ /bin/cat << EOF > ${TMP_CTRL_FILE} EOF # ステータス初期値設定 RTN_STATUS=${RTN_NORMAL} # sqlldr LOG_STR=`log_output I "sqlldr ${SCHEMA}/${PASSWORD_MASKING} control=${TMP_CTRL_FILE}" ` echo ${LOG_STR} sqlldr ${SCHEMA}/${PASSWORD} control=${TMP_CTRL_FILE} Rtn=$? if [ ${Rtn} -ne 0 ]; then LOG_STR=`log_output C "RTN_STATUS=${Rtn} 異常終了 : DB展開(${SHELL_BASENAME})" ` echo ${LOG_STR} RTN_STATUS=${RTN_ERROR} else LOG_STR=`log_output I "正常終了 : DB展開(${SHELL_BASENAME})" ` echo ${LOG_STR} fi rm -f ${TMP_CTRL_FILE} exit ${RTN_STATUS} } # =============================================================================# # 変数初期化 # =============================================================================# SCHEMA="" PASSWORD="" # 引数取得 TOOL_ARG=$* # 引数チェック for ARG in ${TOOL_ARG}; do # 引数の最初の2文字 val1=`echo $ARG | awk '{val1=substr($1,1,2); print(val1);}'` # 引数の3文字目以降 val2=`echo $ARG | awk '{val2=substr($1,3); print(val2);}'` # スキーマ名 if [ "${val1}" = "-s" ];then # 重複チェック if [ "${SCHEMA}" != "" ];then LOG_STR=`log_output C "[${val1}]スキーマ名重複指定"` error_message exit ${RTN_ERROR} elif [ "${val2}" = "" ];then LOG_STR=`log_output C "[${val1}]スキーマ名不正"` error_message exit ${RTN_ERROR} fi SCHEMA=${val2} # パスワード elif [ "${val1}" = "-p" ];then # 重複チェック if [ "${PASSWORD}" != "" ];then LOG_STR=`log_output C "[${val1}]パスワード重複指定"` error_message exit ${RTN_ERROR} elif [ "${val2}" = "" ];then LOG_STR=`log_output C "[${val1}]パスワード不正"` error_message exit ${RTN_ERROR} fi PASSWORD=${val2} fi done # 必須引数指定確認チェック if [ "${SCHEMA}" = "" ];then LOG_STR=`log_output C "スキーマ名未指定"` error_message exit ${RTN_ERROR} elif [ "${PASSWORD}" = "" ];then LOG_STR=`log_output C "パスワード未指定"` error_message exit ${RTN_ERROR} fi # 日付 DATE=`date +%Y%m%d` DATE_ALL=`date +%Y%m%d%H%M%S` # ログファイル LOG_DIR="." LOGFILE=${LOG_DIR}/${SHELL_BASENAME}_${DATE_ALL}.log # =============================================================================# # 主処理実行 # =============================================================================# main $* 1>>${LOGFILE} 2>&1
最新コメント