---
title: "shell ssh login script and awk used"
author: "wangmingming2008"
date: "2014-04-13T19:10:23Z"
tags: []
categories: ["操作系统"]
slug: "shell-ssh-login-script-and-awk-used"
draft: false
lastmod: "2014-04-13T19:10:23Z"
id: 2044477
url: "https://wangmingming2008.iteye.com/blog/2044477"
---

pwz:ssh $ cat goto.sh 
#/bin/bash

_go=$1

_ip_config=/Users/pwz/ssh/game_ip.config

if ;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 ;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 ;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 ;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