Script to Start SAProuter on Unix

SAProuter on Unix

Here is a script to start the SAProuter in an easy way on Unix. Just put the content below in a sh file, and pay attention to the variables. Then, execute “sh start_saprouter.sh” for example, or put a schedule on it.


start_saprouter.sh

### Variables ###
porta=”3299″;
SECUDIR=”/usr/sap/saprouter”;
SNC_LIB=”/usr/sap/saprouter/libsapcrypto.so”;
DNAME=”p:CN=server, OU=0001000000, OU=SAProuter, O=SAP, C=DE”;
### Variables end ###

### Check if saprouter is already running:
pid1=”`netstat -nlp | grep ‘0.0.0.0:'”$porta”‘.*saprouter’ | sed -n 1p |awk ‘{print $7}’ | cut -f1 -d “/” `”;

if [ -f $pid1 ]

then # Not running.

  ### check if the port is free:
echo -e “\nChecking port…”;
processo=”`netstat -nlp | grep 0.0.0.0:”$porta” | sed -n 1p |awk ‘{print $7}’ | cut -f1 -d “/”`”;
sleep 2;

  # If port free:
if [ -f $processo ]
then
echo -e ‘\nStarting SAPRouter on port: ‘ $porta;
sleep 2;
export SECUDIR=$SECUDIR
export SNC_LIB=$SNC_LIB

  /usr/sap/saprouter/./saprouter -r -R “$SECUDIR/saprouttab” -W 60000 -G “$SECUDIR/saprouterlog.txt” -S $porta -K “$DNAME” &

  pid=”`netstat -nlp | grep ‘0.0.0.0:'”$porta”‘.*saprouter’ | sed -n 1p |awk ‘{print $7}’ | cut -f1 -d “/” `”;
echo -e “\n\nSAPRouter is running on PID: “$pid;
echo -e “\n”;
exit;
# if the port isnot free.

  else
echo -e ‘——————————————————-\n’;
echo -e ‘ It is not possible to start SAPRouter\n’;
echo -e ‘ The PID: ‘$processo’ is already using the port: ‘ $porta;
echo -e ‘——————————————————-\n’;
fi

  ###################
else # Its already running.
echo -e “\nSAPRouter is already running”;
pid=”`ps -ef |grep saprouter | sed -n 1p |awk ‘{print $2}’ `”;
echo -e “\nPID: “$pid;
echo -e “\n”;
sleep 2;
fi

Author: Richard Brehmer

Richard has his degree in information systems, specializing in IT infrastructure, focused on SAP and Oracle environments. Enthusiast in SAP and Oracle technologies, currently working as SAP Basis at Teiko Soluções em TI, providing support to SAP and Oracle database administration.

Module(s): Basis, Netweaver