概述
#!/bin/bash
echo "args:$*"
if [ "$#" != "1" ]
then
echo "must have 1 args, but only has $# args."
exit 1
fi
echo "set var"
#shell params
ruleId=$1
echo "ruleId="$ruleId
#split ruleId by ","
OLD_IFS="$IFS"
IFS=","
ruleIds=($ruleId)
IFS="$OLD_IFS"
len=${#ruleIds[@]}
echo "has $len ruleId"
#begin
#do same thing
echo "begin..."
echo "executeJar"
for id in ${ruleIds[@]}
do
javacmd="java -jar -Dfile.encoding=gbk jar_name.jar $id $dateId $latnId"
echo $javacmd
$javacmd
if [ $? -eq 0 ]
then
echo $?
echo 'ok'
else
echo $?
#强制退出
exit 1;
fi
echo "executeJar end ruleId:$id"
done
echo "End executeJar all ruleIds."
echo "END"
[root@bd129106 shell]# ./show.sh 1,2,3
args:1,2,3
set var
ruleId=1,2,3
has 3 ruleId
begin...
executeJar
java -jar -Dfile.encoding=gbk jar_name.jar 1
Error: Unable to access jarfile jar_name.jar
1
最后
以上就是精明枕头为你收集整理的shell循环执行jar,异常时退出循环的全部内容,希望文章能够帮你解决shell循环执行jar,异常时退出循环所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复