执行脚本拉去远程服务器mysql数据

#!/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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值