批量导入xml到informatica repository中的shell script

前端之家收集整理的这篇文章主要介绍了批量导入xml到informatica repository中的shell script前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

主要利用pmrep的objectimport命令,该命令执行时需要配置control file(xml文件,配置导入的一些参数和设置)

script:

#!/bin/bash
# -----------------------------------------------------------------------
# Script Name: inf_impobj.sh
# Purpose: To batch import mappings or workflows into repository 
# Created by: Indifferent_to
# Date: 2014-09-30 
# ----------------------------------------------------------------------
function usage {
 cat <<EOUSAGE
 Usage:
    inf_impobj.sh -d <folder> <user_name>
 
 This scirpt will import the file in specified directory.It has a control
 file import_Infa_Objects_Control.txt and a log Infa_import.log.txt. If file
 import into repository successfully,script wil delete the file. If not,the file will be moved to infa_shared/scripts/xml_dir/imp_dir.


 Options:
    -m xml files location
 
 Example:
    inf_impobj.sh -m mluo
EOUSAGE
 exit 1
}
# -----------------------------------------------------------------------
case $1 in
-d)
IMP_PATH=$2/*.xml
shift 1
;;
*)
usage;;
esac


USE_NAME=$2
i=0
j=0
repository="repository name"
domain="repository domain"
host="informatica server host name"
port="informatica server port number"


pmrep connect  -r $repository -h $host -o $port -n $USE_NAME -s $domain 


for FILE_NAME in `ls $IMP_PATH`
do
 pmrep objectimport -i $FILE_NAME -c import_Infa_Objects_Control.txt >Infa_impobj.log
 if [ $? -eq 0 ]
 then
  grep "<Error>" Infa_impobj.log
  if [ $? -eq 0 ]
  then
  echo "$(basename $FILE_NAME) FAIL TO IMPORT"
  let j=$j+1
  mv -f $FILE_NAME  /error
  else
  echo "$(basename $FILE_NAME) IMPORT SUCCESSFULLY!"
  let i=$i+1
  rm $FILE_NAME
  fi
 else
 echo "$(basename $FILE_NAME) FAIL TO IMPORT"
 let j=$j+1
 mv -f $FILE_NAME  /error
 fi
done


echo "$i success; $j fail"
# --------------------------------------------------------------------


control file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE IMPORTPARAMS SYSTEM "/home/informatica/PowerCenter910/server/bin/impcntl.dtd">
<!--IMPORTPARAMS This inputs the options and inputs required for import operation -->
<!--CHECKIN_AFTER_IMPORT Check in objects on successful import operation -->
<!--CHECKIN_COMMENTS Check in comments -->
<!--APPLY_LABEL_NAME Apply the given label name on imported objects -->
<!--RETAIN_GENERATED_VALUE Retain existing sequence generator,normalizer and XML DSQ current values in the destination -->
<!--COPY_SAP_PROGRAM Copy SAP program information into the target repository -->
<!--APPLY_DEFAULT_CONNECTION Apply the default connection when a connection used by a session does not exist in the target repository -->
<IMPORTPARAMS CHECKIN_AFTER_IMPORT="YES(导入完成之后check in)" CHECKIN_COMMENTS="check in时的comment">


<!--FOLDERMAP matches the folders in the imported file with the folders in the target repository -->
<FOLDERMAP
SOURCEFOLDERNAME="source导入的folder"
SOURCEREPOSITORYNAME="source导入的repository"
TARGETFOLDERNAME="target导入的folder"
TARGETREPOSITORYNAME="target导入的repository"/>


<RESOLVECONFLICT>

(解决同名冲突的方式,替换、重用。。。) <TYPEOBJECT OBJECTTYPENAME="WORKFLOW" RESOLUTION="REPLACE"/> <TYPEOBJECT OBJECTTYPENAME="WORKLET" RESOLUTION="REUSE"/> <TYPEOBJECT OBJECTTYPENAME="SESSION" RESOLUTION="REPLACE"/> <TYPEOBJECT OBJECTTYPENAME="MAPPING" RESOLUTION="REPLACE"/> <TYPEOBJECT OBJECTTYPENAME="MAPPLET" RESOLUTION="REPLACE"/> <TYPEOBJECT OBJECTTYPENAME="Source definition" RESOLUTION="REPLACE"/> <TYPEOBJECT OBJECTTYPENAME="Target definition" RESOLUTION="REPLACE"/> <TYPEOBJECT OBJECTTYPENAME="Expression" RESOLUTION="REPLACE"/> <TYPEOBJECT OBJECTTYPENAME="Filter" RESOLUTION="REPLACE"/> <TYPEOBJECT OBJECTTYPENAME="Aggregator" RESOLUTION="REPLACE"/> <TYPEOBJECT OBJECTTYPENAME="Rank" RESOLUTION="REPLACE"/> <TYPEOBJECT OBJECTTYPENAME="Normalizer" RESOLUTION="REPLACE"/> <TYPEOBJECT OBJECTTYPENAME="Router" RESOLUTION="REPLACE"/> <TYPEOBJECT OBJECTTYPENAME="Sequence" RESOLUTION="REPLACE"/> <TYPEOBJECT OBJECTTYPENAME="Sorter" RESOLUTION="REPLACE"/> <TYPEOBJECT OBJECTTYPENAME="update strategy" RESOLUTION="REPLACE"/> <TYPEOBJECT OBJECTTYPENAME="Custom Transformation" RESOLUTION="REPLACE"/> <TYPEOBJECT OBJECTTYPENAME="Lookup Procedure" RESOLUTION="REPLACE"/> <TYPEOBJECT OBJECTTYPENAME="Transaction control" RESOLUTION="REPLACE"/> <TYPEOBJECT OBJECTTYPENAME="Stored Procedure" RESOLUTION="REPLACE"/> <TYPEOBJECT OBJECTTYPENAME="External Procedure" RESOLUTION="REPLACE"/> <TYPEOBJECT OBJECTTYPENAME="Joiner" RESOLUTION="REPLACE"/> <TYPEOBJECT OBJECTTYPENAME="SessionConfig" RESOLUTION="REUSE"/> <TYPEOBJECT OBJECTTYPENAME="Email" RESOLUTION="REPLACE"/> <TYPEOBJECT OBJECTTYPENAME="Command" RESOLUTION="REPLACE"/> <TYPEOBJECT OBJECTTYPENAME="Scheduler" RESOLUTION="REPLACE"/> </RESOLVECONFLICT> </IMPORTPARAMS>

猜你在找的XML相关文章