-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloop_run.sh
51 lines (42 loc) · 1.15 KB
/
loop_run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
# 避免 Oracle 乱码
export NLS_LANG="AMERICAN_AMERICA.AL32UTF8"
INDEX_arr=(0 1)
SUB_DIR_arr=(model1 model2)
USER_arr=(model1 model2)
PASS_arr=(model1 model2)
# 读取流水线写入的 IP
IPs=`cat IPs`
echo $IPs
# 分割 IP 为数组
IParr=(${IPs//[^0-9.]/ })
echo ${IPs//[^0-9.]/ }
for IP in ${IParr[@]}
do
echo
echo \# $IP
DIR_arr=(`ls -d 2*/*/*/*`)
for DIR in ${DIR_arr[@]}
do
echo
echo \#\# cd $DIR
cd $DIR
for i in ${INDEX_arr[@]}
do
# -a -e 通用 -d 目录 -f 文件 -s 不为空 -z 为空 -r 可读 -w 可写 -x 可执行
if [ ! -d "${SUB_DIR_arr[$i]}" ];then
continue
fi
echo
echo \#\#\# cd ${SUB_DIR_arr[$i]}
cd ${SUB_DIR_arr[$i]}
echo \#\#\# start ${USER_arr[$i]}/***@$IP:1521/ORCL @oracle_run.sql
# sqlplus ${USER_arr[$i]}/${PASS_arr[$i]}@$IP:1521/ORCL @oracle_run.sql
# -v 显示日志 -U 禁止无 where 更新
# mysql -v -U -u${USER_arr[$i]} -p${PASS_arr[$i]} -h $IP -P 3306 --default-character-set=utf8mb4 < mysql_run.sql
echo \#\#\# end ${USER_arr[$i]}/***@$IP:1521/ORCL @oracle_run.sql
cd ..
done
cd ..
done
done