#!/bin/bash
function down_load_file(){
source_ip="$1$2"
command="scp -P10022 $source_ip@$source_ip:~/$4 $5"
expect -c "
set timeout 36000;
spawn $command;
expect {
\"(yes/no)?\" {send \"yes\r\"; exp_continue}
\"$source_ip's password:\" {send \"$3\r\"; exp_continue}
}"
}
#exit
###########################################################
#
platform="abc.com"
db_name="name_"
for a in 3 4
do
svr_idx="s$a"
db=$db_name"s$a"
src_file=$svr_idx"_level.txt"
dest_file="abc"$svr_idx"_level.txt"
#sql_commond="mysql -uroot -p123456 -h 127.0.0.1 $db -e \"select level,count(*) from t_character_info where char_flag=0 group by level order by level;\" > $src_file "
sql_commond="mysql -uroot -p123456 -h 127.0.0.1 $db -e \"select level,platform_gamesvr_id from t_character_info where char_flag=0 and level=17 and platform_gamesvr_id not like '%Theokole%';\" > $src_file "
echo $platform $sql_commond
s_pwd="000000"
ssh -p10022 $svr_idx"-"$platform@$svr_idx"-"$platform $sql_commond
down_load_file $svr_idx"-" $platform $s_pwd $src_file $dest_file
done
执行脚本拉去远程服务器mysql数据
最新推荐文章于 2024-07-21 03:24:55 发布