Last active
August 29, 2015 14:22
-
-
Save sowe/28ca59de9c59cc873cec to your computer and use it in GitHub Desktop.
HellKichen Shell script to run a ETL process v1.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# The user's home directory | |
USER_HOME=$(eval echo ~${SUDO_USER}) | |
FILE=${USER_HOME}/.kettel/kettle_config.properties | |
# time | |
NOW=$(date +"%d%m%Y_%H%M%S") | |
NOW_TIME=$(date +"%d/%m/%Y")" "$(date +"%H:%M:%S") | |
LOG=$NOW_$3.log | |
pdi=$(grep -i 'PATH_TO_DATA_INTEGRATION' $FILE | cut -f2 -d'=') | |
log=$(grep -i 'PATH_TO_LOGS' $FILE | cut -f2 -d'=') | |
PATH_TO_DATA_INTEGRATION=$pdi | |
PATH_TO_LOGS=$log | |
echo -e "\033[32mRunning a ETL process" $NOW_TIME | |
if [ $# -eq 3 ];then | |
if [ -f $1 ]; then | |
cd $PATH_TO_DATA_INTEGRATION | |
echo $1 | |
if [[ $1 =~ \.kjb$ ]]; then | |
./kitchen.sh -file=$1 -level=$2 > $PATH_TO_LOGS$LOG | |
echo "job" | |
else | |
./pan.sh -file=$1 -level=$2 > $PATH_TO_LOGS$LOG | |
echo "ktr" | |
fi | |
case $? in | |
0) echo "-> The job ran without a problem." >> $LOG ;; | |
1) echo "-> Errors occurred during processing." >> $LOG ;; | |
2) echo "-> An unexpected error occurred during loading / running of the job." >> $LOG ;; | |
7) echo "-> The job couldn't be loaded from XML or the Repositorn." >> $LOG ;; | |
8) echo "-> Error loading steps or plugins (error in loading one of the plugins mostly)." >> $LOG ;; | |
9) echo "-> Command line usage printing." >> $LOG ;; | |
esac | |
else | |
echo -e "\033[31m Error!!!! the ETL process don't exist" | |
fi | |
else | |
echo -e "\033[33mParamters {PATH_TO_ETL | LOG level | LOG_NAME_WITH_OUT_EXTENSION}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment