批量导出informatica object 的shell script

#!/bin/bash  
# -----------------------------------------------------------------------
# Script Name: inf_impobj.sh
# Purpose: To batch export mappings or workflows to xml files 
# Created by: indifferent_to
# Date: 2014-11-26 
# ----------------------------------------------------------------------
function usage {
cat <<EOU
Usage:
    inf_impobj.sh -l <list_file> -d <output_folder> -w/-m/-s/-t <user_name>
EOU
exit 1
}
repository="repository name"
domain="repository domain"
host="informatica server host name"
port="informatica server port number"
_user_name=
_password=
_obj_type=mapping
list_file=
output_folder=

if [ ! -n "$1" ]; then
usage
else
while true
do
case $1 in
-l)
list_file=$2
shift 2;;
-d)
output_folder=$2
shift 2;;
-w)
_obj_type=workflow
_user_name=$2
break;;
-s)
_obj_type="source"
_user_name=$2
break;;
-t)
_obj_type="target"
_user_name=$2
break;;
-m)
_user_name=$2
break;;
*)
if [ ! -n "$1" ]; then
	break;
        usage
else
        echo "invalid argument $1";
        break;	
	usage
fi
        ;;
esac
done
fi

pmrep connect  -r $repository -h $host -o $port -n $_user_name -s $domain
if [ $? -ne 0 ]; then
echo "Can not connect to the informatica repository!"
exit 1; 
fi

row_count=`cat $list_file|wc -l`
success=0
fail=0

for((row=1;row<=$row_count;row++))
do
object_name=`sed -n ${row}'p' $list_file`
object_name=`echo $object_name|sed 's/\\r//g'`

#pmrep objectexport -n $object_name -o $_obj_type -m -f client_delpdw -s -b -r -u ${output_folder}/${object_name}".xml">>infa_expobj.log
pmrep objectexport -n $object_name -o $_obj_type -m -f client_delpdw -b -u ${output_folder}/${object_name}".xml">>infa_expobj.log

if [ $? -eq 0 ]; then
	let success=$success+1
        echo "${object_name} export successfully!"
else
	let fail=$fail+1
	echo "${object_name} fail to export."
fi

#if [ _obj_type="sourcce" ]; then
#new_object_name=`echo $object_name|sed 's/flatfile.//g'`
#mv ${output_folder}/${object_name}".xml"  ${output_folder}/${new_object_name}".xml"
#fi

done

echo "$success success;	$fail fail"

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。