switch 切换目录
1
2
3
4
5
6#!/usr/bin/expect -f
set dirname [lindex $argv 0]
spawn sudo su - $dirname
expect "adminlp:"
send "adminlp@v\$3234\r"
interactcp 拷贝
1
2
3
4
5
6
7#!/usr/bin/expect -f
set file [lindex $argv 0]
set dir [lindex $argv 1]
spawn sudo cp $file $dir
expect "adminlp:"
send "adminlp@v\$3234\r"
interactcmd 串行执行
1
2
3
4
5
6
7
8
9
10
11
file=$1
cmd=$2
num=1
for ip in `cat $file|grep -v "#"|awk '{print $2}'|sort|uniq`;do
echo "$num: $ip:"
#ssh mrdTomcat@$ip "$cmd"
ssh $ip "$cmd"
echo
num=$(($num+1))
donescp 串行拷贝
1
2
3
4
5
6
7
8
9
file=$1
scp_s=$2
scp_d=$3
for ip in `cat $file|grep -v "#"|awk '{print $2}'|sort|uniq`;do
echo "$ip:"
scp $scp_s mrdTomcat@$ip:$scp_d
done