持之以恒

导航

call expect script content in bash shell

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

posted on 2021-11-10 13:56  beilei  阅读(11)  评论(0编辑  收藏  举报