shell ssh login script and awk used

pwz:ssh $ cat goto.sh
#/bin/bash

_go=$1

_ip_config=/Users/pwz/ssh/game_ip.config

if [ ! -f ${_ip_config} ];then
echo "game_ip.config file not found in the path:"$_ip_config
return
fi

#gtip=echo awk -F: '($1==$_go){print $2}' $_ip_config
#echo $gtip
for game_ip in $(awk -F: '{print $0}' $_ip_config);
do
#echo $game_ip
game=$(echo $game_ip|awk -F: '{print $1}');
ip=$(echo $game_ip|awk -F: '{print $2}');
if [ $game == $_go ];then
ssh root@$ip
fi
done

game_ip.config
nba_nginx:10.52.35.231
iamslots_x2:10.51.35.33
nba_iostest:10.52.32.179
csj_s1:10.52.35.155
csj_s36:10.52.33.128
nba_iostest:10.52.32.179
nba_test2:10.30.38.142
nba_nginx:10.52.35.231
nba_log:10.52.35.233
nba_db:10.52.35.231
csj_iostest:10.52.33.135
tth_iostest:10.52.35.128
local_nba_iostest:10.51.35.245
usa_platfrom:10.51.32.57
tth_s19:10.52.32.196
slots_iostest:10.51.32.27
tw_pmc:10.30.33.61


#/bin/bash

echo $0

_IP=$1
_DB=$2
_PORT=$3
_START=$4
_END=$5
_DATE=$(date +%Y%m%d);

_OUT_FILE=iamslots_${_IP}_${_DATE}_$_PORT.txt


if [ -f $_OUT_FILE ];then
rm -rf $_OUT_FILE
echo 'delete '$_OUT_FILE' successfully!'
else
echo "Frist to query the log..."
fi


for((d=$_START;d<=$_END;d++))
do
#echo "start to do table "$d
out1=$(mysql -ustat -ppetnewstatZL123 -h$_IP -D$_DB -P$_PORT --secure_auth=off -e "select account_id,reason,add_buy_gold,gold_type,log_time,device_type from money_log_$d where reason in (4001,14001);" >> $_OUT_FILE);
printf ">>>>>>>>>>>>>:"$d
#echo mysql -ustat -ppetnewstatZL123 -h$_IP -D$_DB
done

#rm -rf slot_${_IP}_$_DATE.txt

#touch slot_${_IP}_$_DATE.txt

if [ -f $_OUT_FILE ];then
#rm -rf slot_${_IP}_$_DATE.txt
#
awk '{(tot+=$3)}; END {print "iamslots ip:${_IP} port:${_PORT} total:" tot}' $_OUT_FILE >> $_OUT_FILE
else

echo "File not create."
fi
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值