call expect script content in bash shell

expect <<EOF
set timeout 10
spawn ssh $user@$ip
expect {
"yes/no" { send "yes ";exp_continue }
"password" { send "$password " }
}
expect "]#" { send "useradd hehe " }
expect "]#" { send "echo rrr|passwd --stdin hehe " }
expect "]#" { send "exit " } expect eof
EOF

原文地址:https://www.cnblogs.com/beilei123/p/15533272.html