实际开发中,经常会遇到java需要调用/得到shell脚本的返回值,进行下一步开发,所以我写了一个工具类,供以后大家使用。
process2.sh:
#!/bin/bash
function process(){
#echo $1,$2,$3,$4,$5
#if [[ $1 -eq 0 && $2 -eq 0 && $3 -eq 1 && $4 -eq 1 && $5 -eq 1 ]]
#then
#return 200
#fi
if [[ $1 -eq 0 && $2 -eq 0 && $3 -eq 2 && $4 -eq 2 && $5 -eq 2 ]]
then
#return 0
echo 0
fi
if [[ $1 -lt 1 && $2 -lt 1 ]]
then
if [[ $3 -eq 1 || $4 -eq 1 || $5 -eq 1 ]]
then
killall 雪盈证券
killall stockAlert
ps -ef|grep chromedriver|awk '{print $2}'|xargs kill -9
sleep 1
nohup /Users/a123/Downloads/chromedriver-v10.1.2-mas-x64/chromedriver >> chromedivier.out &
sleep 1
nohup java -jar stockAlert-1.0-SNAPSHOT-jar-with-dependencies.jar >> stockAlert.out &
sleep 1
echo "" > ./stock_log_file.log
sleep 1
#return 2
echo 2
fi
if [[ $3 -gt 2 || $4 -gt 2 || $5 -gt 2 ]]
then
killall stockAlert
killall 雪盈证券
#killall chromedriver
ps -ef|grep chromedriver|awk '{print $2}'|xargs kill -9
sleep 1
nohup /Users/a123/Downloads/chromedriver-v10.1.2-mas-x64/chromedriver >> chromedivier.out &
sleep 1
nohup java -jar stockAlert-1.0-SNAPSHOT-jar-with-dependencies.jar >> stockAlert.out &
sleep 1
echo "" > ./stock_log_file.log
sleep 1
#return 3
echo 3