ParseInstance()
{
Files=`find ${JMS_UTIL_CONFIG_PATH} -name "*.jms.properties" | grep -v common | sort`
FileCount=`echo "${Files}"|wc -w|tr -d ' '`
[ $FileCount -le 0 ] && { echo "Not found config files in ${JMS_UTIL_CONFIG_PATH}....."; return 1; }
INDEX=1
for file in ${Files}; do
FileName=`basename ${file}`
read ENV SYSTEM <<< `echo ${FileName} | awk -F . '{print $1, $2}'`
EnvCount=`echo "${ENV}" | wc -w | tr -d ' '`
SystemCount=`echo "${SYSTEM}" | wc -w | tr -d ' '`
[ ${EnvCount} -le 0 -o ${SystemCount} -le 0 ] && { echo "Invalid config file found: ${FileName}"; return 1; }
ENVCAP=`echo "${ENV}" | tr 'a-z' 'A-Z'`
SYSTEMCAP=`echo "${SYSTEM}" | tr 'a-z' 'A-Z'`
ENVARRAY[${INDEX}]=${ENV}
SYSARRAY[${INDEX}]=${SYSTEM}
echo ${INDEX}. ${SYSTEMCAP} ${ENVCAP}
INDEX=`expr ${INDEX} + 1`
done
}
ParseDestination()
{
SYS=`echo "${system}" | tr 'a-z' 'A-Z'`
ParseConf ${JMS_UTIL_DEST_CONFIG} ${SYS}
DESTINX=1
for line in ${SectionItems}; do
if [ "${line:0:1}" == "[" ]; then
continue;
fi
read DESTNAME DESTVALUE <<< `echo ${line} | awk -F = '{print $1, $2}'`
DESTARRAY[${DESTINX}]=${DESTVALUE}
echo ${DESTINX}. ${DESTNAME}
DESTINX=`expr ${DESTINX} + 1`
done
}
ParseConf()
{
ENVCONF=$1
Section=$2
[ ! -f $ENVCONF ] && { echo "Not found $ENVCONF...."; return 1; }
Section=`echo "${Section}"|tr -d ' '`
SectionLen=`echo "${Section}"|wc -w|tr -d ' '`
[ $SectionLen -le 0 ] && { echo "Section name is empty...."; return 1; }
LeftIndexList=`sed -n -e "/\[/ =" $ENVCONF|tr "\n" " " `;
LeftIndexLen=`echo "${LeftIndexList}"|wc -w|tr -d ' '`;
[ $LeftIndexLen -le 0 ] && { echo "Unknown format in $ENVCONF...."; return 1; }
LastLeftIndex=`echo "${LeftIndexList}"|awk '{print $NF}'`
SectionIndex=`sed -n -e "/\[$Section\]/ =" $ENVCONF`
isOK=$?
SectionIndexLen=`echo "${SectionIndex}"|wc -w|tr -d ' '`
[ $isOK -ne 0 -o $SectionIndexLen -le 0 ] && { echo "Not found $Section in $ENVCONF....."; return 1; }
SectionEndLine="\["
[ $LastLeftIndex -eq $SectionIndex ] && { SectionEndLine="\\$"; }
SectionItems=`sed -n -e "$SectionIndex,/$SectionEndLine/p" $ENVCONF`
SectionItemsLines=`echo "${SectionItems}"|wc -l |tr -d ' '`
[ $SectionItemsLines -le 0 ] && { echo "Not found the content of $Section in $ENVCONF....."; return 1; }
return 0
}
JMS_UTIL_HOME=.
JMS_UTIL_CONFIG_PATH=${JMS_UTIL_HOME}/jms-properties
JMS_UTIL_DEST_CONFIG=${JMS_UTIL_CONFIG_PATH}/destinations.properties
JMS_UTIL_CLASSPATH=`ls *.jar`
CLASSPATH=.:${JMS_UTIL_CLASSPATH}:$TPS_CASH_COMMON_CLASSPATH:$CLASSPATH
echo EMS Instances
echo ---------------
ParseInstance
echo ---------------
NUMOFOPT=${#ENVARRAY[@]}
INPUT=
while true; do
echo "Please select EMS instance:"
read INPUT
RESULT=`expr match $INPUT '\([0-9]*\)'`
echo "INPUT: ${INPUT} / RESULT: ${RESULT}"
if [[ "${INPUT}" != "${RESULT}" ]]; then
echo "Invalid input. Try again..."
echo
continue;
elif [ ${INPUT} -lt 1 -o ${INPUT} -gt ${NUMOFOPT} ]; then
echo "${INPUT} is not in the list. Try again..."
echo
else
environment=${ENVARRAY[$INPUT]}
system=${SYSARRAY[$INPUT]}
break;
fi
done
echo Destinations
echo ---------------
ParseDestination
echo ---------------
NUMOFOPT=${#DESTARRAY[@]}
INPUT=
while true; do
echo "Please select destination:"
read INPUT
RESULT=`expr match $INPUT '\([0-9]*\)'`
echo "INPUT: ${INPUT} / RESULT: ${RESULT}"
if [[ "${INPUT}" != "${RESULT}" ]]; then
echo "Invalid input. Try again..."
echo
continue;
elif [ ${INPUT} -lt 1 -o ${INPUT} -gt ${NUMOFOPT} ]; then
echo "${INPUT} is not in the list. Try again..."
echo
else
destination=${DESTARRAY[$INPUT]}
break;
fi
done
INPUT=
while true; do
echo "Please enter the path of message file or directory contains message files:"
read INPUT
if [ ! -e ${INPUT} ]; then
echo "File or Directory doesn't exists. Try again..."
echo
continue;
elif [ -d ${INPUT} ]; then
DirPath=${INPUT}
break;
else
FilePath=${INPUT}
IsFile=true
break;
fi
done
if [ "${IsFile}" == "true" ]; then
INPUT=
while true; do
echo "Please enter times you want to publish:"
read INPUT
RESULT=`expr match $INPUT '\([0-9]*\)'`
if [[ "${INPUT}" != "${RESULT}" ]]; then
echo "Invalid input. Try again..."
echo
continue;
else
times=${INPUT};
break;
fi
done
fi
tester=`whoami`
$JAVA_HOME/bin/java -Denvironment=${environment} -Dsystem=${system} -Ddestination=${destination} -Dfile.path=${FilePath} -Ddir.path=${DirPath} -Dtimes=${times} -Dtester=${tester} com.kevin.test.jms.TestSender >> stress_testing.log
相关推荐
### Shell Script 编程学习笔记 #### 一、Shell 脚本初窥 ##### 示例: ```bash #!/bin/sh # 第1行:指定脚本解释器(声明使用的shell名称),这里是用/bin/sh做解释器的。“#!”是一个约定的标记 cd ~ # 第2行:...
一直很喜欢写unix shell script, 因为写那么一点点东西可以有那么多效果,投入小,产出大,爽啊. 在写IBM AIX K Shell script时,感觉不那么友好,主要是有一些格式细节要求比较严格,不太习惯,后来写惯了也就好了,下面的...
5. **流程控制**:Shell Script 支持多种流程控制结构,如条件判断 (`if...then...else`) 和循环 (`for`, `while`) 等,这使得脚本能够处理更复杂的逻辑。 #### 四、Bourne Shell (Bash) 1. **变量类型**:Bourne ...
shfmt_v3.1.2_windows_amd64.exe shfmt_v3.1.2_windows_386.exe 解决idea would you like to install a shell script formatter?的问题
Jenkins构建Execute shell script on remote host using ssh命令;JenkinsSSH执行命令;
Chapter 9 - Web and Internet Administration Chapter 10 - Internet Server Administration Chapter 11 - Mac OS X Scripts Chapter 12 - Shell Script Fun and Games Afterword Index ...
Premier Press - Microsoft Windows Shell Script Programming for the Absolute Beginner.pdf Premier Press - Microsoft Windows Shell Script Programming for the Absolute Beginner.pdf Premier Press - ...
身為 UNIX 系統管理者除了要熟悉 UNIX 指令外,我們最好學會幾種 scripts 語言,例如 shell script 或 perl。學會 script 語言後,我們就可以將日常的系統管理工作寫成一支執行檔,如此一來,在管理系統時就可以更加...
3. **条件判断和循环**:Shell 脚本支持使用 if 语句进行条件判断以及 for 和 while 循环来重复执行一组命令。例如: ```bash i=1 while [ $i -le 5 ]; do echo "Number: $i" i=$((i + 1)) done ``` 4. **...
shell script 交互语法shell script 交互语法shell script 交互语法shell script 交互语法shell script 交互语法shell script 交互语法shell script 交互语法shell script 交互语法
### Shell Script详解 #### 一、Shell Script简介与特点 Shell Script是一种用于自动化任务处理的脚本语言,广泛应用于Linux及类Unix系统中。通过Shell Script,用户可以编写一系列命令来实现复杂的操作流程,提高...
### Shell Script语言教程知识点概述 #### 一、Shell Script简介 **Shell Script**是一种脚本语言,用于控制Unix操作系统(包括Linux)中的各种任务。它主要用于自动化任务、管理文件和目录以及执行系统管理任务。...
在Jenkins构建springboot项目自动部署的时候,配置远程执行Dockerfile所在服务器的SSH命令,这里把完整的命令贴出来,详细搭建过程见我的博客《基于Jenkins+Gitlab+Docker实现SpringBoot项目自动部署》
"利用LINUX SHELL Script实现数据库系统管理" 在本篇文章中,我们将讨论如何使用LINUX SHELL Script来实现数据库系统管理。数据库是许多应用业务系统的核心设施,因此对数据库的测试、监控和维护非常重要。本文将...
### Shell Script程序设计 #### 基础概念与特点 Shell Script是一种强大的脚本语言,主要用于控制基于Unix的系统(包括Linux)。它允许用户通过编写一系列的命令来自动化任务,这些命令可以是简单的文件操作、打印...
Shell脚本编程(scripting)的技巧永远不会过时:它们可以让UNIX充分发挥其真实的潜能。对UNIX的用户与系统管理者而言,编写Shell脚本是必须的工作,它可以让你快速地控制与定制任何UNIX系统的强大功能。有了Shell...