需求: 日常工作经常需要将传输从一个系统传到别一个系统 ,需手工拷贝传输的数据文件和控制文件
前提: SAP服务器名字: <sapsid>a 例子: D4C 系统主机是 d4ca ;Q4C 系统主机是q4ca
#!/bin/bash ##################################################################################################################### #auther : __tingxin__ # #date : 2020-Mar-29 # #version: 1.0 # #Funtion: 远程将传输号从一个SAP服务器复制到另一个服务器并加入到传输队列 # # # # # #parametr: # # <Transport_number> 传输号 # # <SAPSID> 目标SAP系统SAPID # #usage : trcopy Transport_number SAPSID # # # ##################################################################################################################### if [ $# -lt 2 ] then print "==========================================================" print "check_backup - check if backup exist for date" print "Syntax: remotetecopy <Transport_number> <SAPSID>" exit 8 fi typeset -u STR=$1 echo $STR SSID="" ssid="" shost="" transportid="" TSID=$2 typeset -l tsid=$2 targethost=${tsid}a if [ ${#STR} -eq 10 ]; then SSID=$(echo $STR|cut -c 1-3) echo "Source system is $SSID" typeset -l ssid=$SSID shost=${ssid}a #source host echo "Source host is $shost" transportid=${SSID}K$(echo $STR|cut -c 5-10) echo "transport number is $transportid" trcofile=K$(echo $STR|cut -c 5-10).${SSID} trdatafile=R$(echo $STR|cut -c 5-10).${SSID} else SSID=$(echo $STR|cut -c 9-11) #source SAPSID echo "Source system is $SSID" typeset -l ssid=$SSID shost=${ssid}a #source host echo "Source host is $shost" transportid=${SSID}K$(echo $STR|cut -c 2-7) echo "transport number is $transportid" trcofile=K$(echo $STR|cut -c 2-7).$SSID trdatafile=R$(echo $STR|cut -c 2-7).$SSID fi ssh $shost "test -e "/usr/sap/trans/cofiles/${trcofile}"" if [ $? -eq 0 ];then echo "$transportid cofiles is exist in host $shost" fi ssh $shost "test -e "/usr/sap/trans/data/${trdatafile}"" if [ $? -eq 0 ];then echo "$transportid data file is exist in host $shost" fi echo "start copy cofile $trcofile" ssh -q $targethost "scp -p $shost:/usr/sap/trans/cofiles/${trcofile} /usr/sap/trans/cofiles/" if [ $? -eq 0 ];then echo "copy cofile $trcofile successfully" fi echo "start copy data $trcofile" ssh -q $targethost "scp -p $shost:/usr/sap/trans/data/${trdatafile} /usr/sap/trans/data/" if [ $? -eq 0 ];then echo "copy cofile $trdatafile successfully" fi echo "start change tranport permission" ssh -q $targethost "chown ${tsid}adm:sapsys /usr/sap/trans/data/${trdatafile}" ssh -q $targethost "chown ${tsid}adm:sapsys /usr/sap/trans/cofiles/${trcofile}" if [ $? -eq 0 ];then echo "change the permission of ${transportid} successfully"fi echo "add transport ${transportid} to buffer" ssh -q $targethost " su - ${tsid}adm -c tp addtobuffer ${transportid} ${TSID} pf=/usr/sap/trans/bin/TP_DOMAIN_${TSID}.PFL" if [ $? -eq 0 ];then echo "add transport ${transportid} to buffer successfully"fi
原文地址:https://www.cnblogs.com/tingxin/p/12591544.html
时间: 2024-11-13 08:53:05