需求: 日常工作经常需要将传输从一个系统传到别一个系统 ,需手工拷贝传输的数据文件和控制文件
前提: SAP服务器名字:
解析: 传输号: DECK000004 有两个文件, 数据文件R000004.DEC 控制文件K000004.DEC
使用方法
remotetecopy DECK000004 D4C
remotetecopy R000004.DEC D4C
remotetecopy K000004.DEC D4C
#!/bin/bash
#####################################################################################################################
#auther : __tingxin__ #
#date : 2020-Mar-29 #
#version: 1.0 #
#Funtion: 远程将传输号从一个SAP服务器复制到另一个服务器并加入到传输队列 #
# #
# #
#parametr: #
#
#
#usage : trcopy Transport_number SAPSID #
# #
#####################################################################################################################
if [ $# -lt 2 ]
then
printf "=========================================================="
printf "check_backup - check if backup exist for date"
printf "Syntax: remotetecopy
exit
fiif [ $(echo $2|cut -c 1) = "P" ]then printf "can't directly import to production system\n" printf "pls start import Develop system first\n" exitfi
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"fiecho "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
结果
root@d4ca:/NT/CCS/script/lih8hz $ remote_tr_copy.sh DECK000004 D4C
DECK000004
Source system is DEC
Source host is deca
transport number is DECK000004
DECK000004 cofiles is exist in host deca
DECK000004 data file is exist in host deca
start copy cofile K000004.DEC
copy cofile K000004.DEC successfully
start copy data K000004.DEC
copy cofile R000004.DEC successfully
start change tranport permission
change the permission of DECK000004 successfully
add transport DECK000004 to buffer
This is tp version 380.70.10 (release 749, unicode enabled)
Warning: Parameter DBLIBPATH is no longer used.
Warning: Parameter DBSWPATH is no longer used.
Addtobuffer successful for DECK000004
tp finished with return code: 0
meaning:
Everything OK
add transport DECK000004 to buffer successfully