总结日常遇到的问题,以及解决办法,总结每天遇到的问题。
2017-12-22 [shell]
登陆服务器每次都输入密码很不舒服,所以总结了一个小脚本。
1#!/bin/bash
2USER=activemq
3current_node=192.168.1.45
4PASSWD=activemq
5/usr/bin/expect <6 spawn ssh $USER@$current_node
7 expect "*(yes/no)?*" {
8 send -- "yes\r"
9 expect "*?assword:*"
10 send -- "$PASSWD\r"
11 } "*?assword:*"
12 send -- "$PASSWD\r"
13 expect "*# "
14 send -- "exit \r"
15EOF
2017-12-21 [shell]
用`,`劈分数据。
1HBASE_REGION=dscn1,dscn2,dscn3
2
3#用 `,` split
4OLD_IFS="$IFS"
5IFS=","
6arr=($HBASE_REGION)
7IFS="$OLD_IFS"
8for s in ${arr[@]}
9do
10 ssh "$s" ls
11done