调用远程资源库转换(ktr)脚本,存放位置/opt/kettle/script
[root@cm01 script]# vim startktr.sh
①调用转换脚本
#!/bin/bash
cmd="sh /opt/kettle/data-integration/pan.sh"
rep="-rep=kettlelib195"
user="-user=xxxx"
pass="-pass=xxxx"
dir="-dir=ktr"
trans="-trans=$1" # 这里的 $1 表示第一个参数(即传入的 test 参数)
level="-level=Basic"
if [ -n "$2" ]; then
dir="-dir=$2"
fi
command="$cmd $rep $user $pass $dir $trans $level"
eval $command
执行:
/opt/kettle/script/startktr.sh ods_pm_t100_pmdt_001 ktr/pm
不用远程资源库执行:
/opt/kettle/data-integration/pan.sh -file=/opt/kettle/transformation/test.ktr
②版本迭代,新增一个参数data,这个参数是日期字段,可灵活更新还是删除那个月/天数据
#!/bin/bash
cmd="sh /opt/kettle/data-integration/pan.sh"
rep="-rep=kettlelib195"
user="-user=kettleauto188"
pass="-pass=auto@188"
dir="-dir=ktr"
trans="-trans=$1" # 这里的 $1 表示第一个参数(即传入的 test 参数)
level="-level=Basic"
today=$(date +"%Y-%m-%d")
# 检查是否有第三个参数(data值)
if [ -n "$3" ]; then
data_param="-param:data=$3"
else
data_param="-param:data=$today"
fi
if [ -n "$2" ]; then
dir="-dir=$2"
fi
command="$cmd $rep $user $pass $dir $trans $level $data_param"
eval $command
eg:
/opt/kettle/script/startktr_para.sh ads_sf_old_system_delivery_001_tmp2 ktr/back 2024-07-01