- cat>forallHost.sh
- #!/bin/bash
- for i in {1..9}
- do
- /usr/bin/expect autoyes.sh $i
- done
- cat>autoyesMkdir.sh
- #!/usr/bin/expect
- set time 1
- set i [ lindex $argv 0 ]
- spawn ssh 192.168.4.$i "mkdir /root/.ssh"
- expect {
- "password:" {send "123456\n"}
- "#" {send "hostname\n"}
- }
- cat>autoyesUprsa.sh
- #!/usr/bin/expect
- set time 1
- set i [ lindex $argv 0 ]
- spawn scp -r /root/.ssh 192.168.4.$i:/root/.ssh
- expect {
- "password:" {send "123456\n"}
- "#" {send "hostname\n"}
- }
- ##################################################################3
- cat uprsa.sh
- #!/bin/bash -r /root/.ssh/ 192.168.4.$i:/root/.ssh/.
- for i in {1..9}
- do
- scp -r /root/.ssh/ 192.168.4.$i:/root/.ssh/.
- done
- cat startvm.sh
- #!/bin/bashsh start rh7_node$i
- for i in {1..9}
- do
- virsh start rh7_node$i
- done
- cat note
- local ip --> 76.121.210.172
- 172.25.254.250
- server -->172.25.0.11
- cat forallHost.sh
- #!/bin/bash
- for i in {1..9}
- do
expect autoues.sh $i
- done
- cat autoyes.sh
- #!/usr/bin/expect
- set time 1
- set i [ lindex $argv 0 ]
- spawn ssh 192.168.4.$i "mkdir /root/.ssh"
- expect {
- "password:" {send "123456\n"}
- "#" {send "hostname\n"}
- }
- cat autoyesUprsa.sh
- #!/usr/bin/expect
- set time 1
- set i [ lindex $argv 0 ]
- spawn scp -r /root/.ssh 192.168.4.$i:/root/.ssh
- expect {
- "password:" {send "123456\n"}
- "#" {send "hostname\n"}
- }
来源: http://www.bubuko.com/infodetail-2687607.html