[SAP BASIS][shell] shell 实战之远程复制传输

Posted A running snail,little step ev

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[SAP BASIS][shell] shell 实战之远程复制传输相关的知识,希望对你有一定的参考价值。

 

需求: 日常工作经常需要将传输从一个系统传到别一个系统 ,需手工拷贝传输的数据文件和控制文件

前提: 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

 

以上是关于[SAP BASIS][shell] shell 实战之远程复制传输的主要内容,如果未能解决你的问题,请参考以下文章

SAP BASIS 基础教程 SAP BASIS daily Job SM13,SM37,SM21

SAP BASIS 基础教程 SAP BASIS daily Job 操作系统日志 ST06,DB12

SAP BASIS 基础教程 SAP BASIS daily Job 查看系统用户 SM04,SP01,SM50

BASIS系列SAP 日志管理

SAP BASIS如何查询指定的用户在SAP系统上做了哪些操作?

SAP BASIS常用T-CODE