+++++++++++++++++++++++++++++++++++++
Title: expect execute commands remotely -02
Time: 3 March 2020
+++++++++++++++++++++++++++++++++++++
#/usr/bin/env expect
set ip 192.168.100.100
set user root
set password centos
set timeout 5
spawn ssh ${user}@${ip}
expect {
"yes/no" { send "yes\r" ; exp_continue }
"password" { send "${password}\r" }
}
expect "#" {
send "usedadd alice\r"
send "echo 123456| passwd --stdin alie\r"
send "id alice\r"
}
expect eof # end of the beginning of the session spawn