Demo entry 6747467

hello

   

Submitted by anonymous on Jun 04, 2018 at 03:27
Language: Bash. Code size: 5.2 kB.

#!/bin/bash												#!/bin/bash
# Program: Audit Trail Report Upload									# Program: Audit Trail Report Upload
#													#

JAVA_HOME=$HOME/jdk1.8.0_151										JAVA_HOME=$HOME/jdk1.8.0_151
export PATH=$JAVA_HOME/bin:$PATH									export PATH=$JAVA_HOME/bin:$PATH

# MAIL_LIST=chunhao.liu@kgi.com,ronny.wu@kgi.com							# MAIL_LIST=chunhao.liu@kgi.com,ronny.wu@kgi.com
MAIL_LIST=$1												MAIL_LIST=$1
[ -z "${MAIL_LIST}" ] && {										[ -z "${MAIL_LIST}" ] && {
	MAIL_LIST=chunhao.liu@kgi.com										MAIL_LIST=chunhao.liu@kgi.com
}													}

YESTERDAY=$2												YESTERDAY=$2
[ -z "${YESTERDAY}" ] && {										[ -z "${YESTERDAY}" ] && {
    YESTERDAY=$(date --date='1 day ago' +%Y%m%d)							    YESTERDAY=$(date --date='1 day ago' +%Y%m%d)
}													}

APP=sv/AuditParser.jar											APP=sv/AuditParser.jar
FIX_DICT=ini/CME_FIX42.xml										FIX_DICT=ini/CME_FIX42.xml
LOG_FILE=history_log/CmegwSv.dug.									LOG_FILE=history_log/CmegwSv.dug.

ECID=6189766												ECID=6189766
MARKETCODE=glbx												MARKETCODE=glbx
PLATFORMCODE=prop											PLATFORMCODE=prop
SESSIONID=RZJ												SESSIONID=RZJ
CLIENTNAME='KGIFutures'											CLIENTNAME='KGIFutures'
ADDITIONALOPTIONALDETAIL='CME'										ADDITIONALOPTIONALDETAIL='CME'

FTP_IP='ftp.newedgegroup.com'										FTP_IP='ftp.newedgegroup.com'
FTP_USR='SDMA-KGI'											FTP_USR='SDMA-KGI'
FTP_PWD='iK18twcod$'											FTP_PWD='iK18twcod$'
REMOTE_PATH=AuditLogFiles										REMOTE_PATH=AuditLogFiles

IP=$(hostname -I)											IP=$(hostname -I)
SCRIPT=$(readlink -f $0)										SCRIPT=$(readlink -f $0)
SYSTEM_HOME=$(dirname $(dirname $(readlink -f $0)))							SYSTEM_HOME=$(dirname $(dirname $(readlink -f $0)))


LOCAL_FILE=history_log/AuditLog_${YESTERDAY}.csv							LOCAL_FILE=history_log/AuditLog_${YESTERDAY}.csv
UPLOAD_FILE=${YESTERDAY}_${ECID}_${MARKETCODE}_${PLATFORMCODE}_${SESSIONID}_${CLIENTNAME}_${ADDI	UPLOAD_FILE=${YESTERDAY}_${ECID}_${MARKETCODE}_${PLATFORMCODE}_${SESSIONID}_${CLIENTNAME}_${ADDI
log=${SYSTEM_HOME}/log/upload_audit_trail.log.${YESTERDAY}						log=${SYSTEM_HOME}/log/upload_audit_trail.log.${YESTERDAY}


main(){													main(){
    echo "STARTUP -> $(date)" | tee -a $log								    echo "STARTUP -> $(date)" | tee -a $log

    echo TIME        = [$(date '+%Y%m%d %H:%M:%S')]:STARTED						    echo TIME        = [$(date '+%Y%m%d %H:%M:%S')]:STARTED

	echo PATH        = [${PATH}]										echo PATH        = [${PATH}]
	echo SYSTEM_HOME = [${SYSTEM_HOME}]									echo SYSTEM_HOME = [${SYSTEM_HOME}]
	echo YESETERDAY  = [${YESTERDAY}]									echo YESETERDAY  = [${YESTERDAY}]
	echo FIX_DICT    = [${FIX_DICT}]									echo FIX_DICT    = [${FIX_DICT}]
	echo LOG_FILE    = [${LOG_FILE}]									echo LOG_FILE    = [${LOG_FILE}]

	echo FTP_IP      = [${FTP_IP}]										echo FTP_IP      = [${FTP_IP}]
	echo LOCAL_FILE  = [${LOCAL_FILE}]									echo LOCAL_FILE  = [${LOCAL_FILE}]
	echo UPLOAD_FILE = [${UPLOAD_FILE}]									echo UPLOAD_FILE = [${UPLOAD_FILE}]
	echo REMOTE_PATH = [${REMOTE_PATH}]									echo REMOTE_PATH = [${REMOTE_PATH}]

	cd $SYSTEM_HOME												cd $SYSTEM_HOME

	java -jar ${APP} ${YESTERDAY} ${FIX_DICT} ${LOG_FILE}							java -jar ${APP} ${YESTERDAY} ${FIX_DICT} ${LOG_FILE}

    mv ${LOCAL_FILE} history_log/${UPLOAD_FILE}								    mv ${LOCAL_FILE} history_log/${UPLOAD_FILE}

	gzip -f history_log/${UPLOAD_FILE}									gzip -f history_log/${UPLOAD_FILE}

    echo "SFTP -> "											    echo "SFTP -> "

#sftp -u ${FTP_USR},${FTP_PWD} ${FTP_IP} << END_FTP							#sftp -u ${FTP_USR},${FTP_PWD} ${FTP_IP} << END_FTP
#cd  ${REMOTE_PATH}											#cd  ${REMOTE_PATH}
#pwd													#pwd
#lpwd													#lpwd
#put ${LOCAL_FILE}.gz -o ${UPLOAD_FILE}.gz								#put ${LOCAL_FILE}.gz -o ${UPLOAD_FILE}.gz
#ls -l ${UPLOAD_FILE}.gz										#ls -l ${UPLOAD_FILE}.gz
#bye													#bye
#END_FTP												#END_FTP

#ls '20180518_6189766_glbx_prop_RZJ_KGIFutures_CME_audittrail.csv.gz'					#ls '20180518_6189766_glbx_prop_RZJ_KGIFutures_CME_audittrail.csv.gz'

ftp -in $FTP_IP << Ftp_cmd 2>&1										ftp -in $FTP_IP << Ftp_cmd 2>&1
user $FTP_USR $FTP_PWD											user $FTP_USR $FTP_PWD
cd  ${REMOTE_PATH}											cd  ${REMOTE_PATH}
put  history_log/${UPLOAD_FILE}.gz ${UPLOAD_FILE}.gz							put  history_log/${UPLOAD_FILE}.gz ${UPLOAD_FILE}.gz
ls ${UPLOAD_FILE}.gz											ls ${UPLOAD_FILE}.gz
bye													bye

Ftp_cmd													Ftp_cmd

}													}

main 2>&1 | tee -a ${log} 										main 2>&1 | tee -a ${log} 

tail -2 ${log} | grep "${UPLOAD_FILE}" && { 								tail -2 ${log} | grep "${UPLOAD_FILE}" && { 
    result=OK 												    result=OK 
    tail -1 ${log}                       | mail -s "${SCRIPT} : ${IP} Upload [CME] Audit Trail R	    tail -1 ${log}                       | mail -s "${SCRIPT} : ${IP} Upload [CME] Audit Trail R
} || { 													} || { 
    result=FAILED											    result=FAILED
    echo "please check the log and inform [it.gw@kgi.com] : ${log}" | mail -s "${SCRIPT} : ${IP}   |	    echo "please check the log : ${log}" | mail -s "${SCRIPT} : ${IP} Upload [CME] Audit Trail R
}													}
echo $result | tee -a ${log}										echo $result | tee -a ${log}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).