<pre name="code" class="sql">#!/bin/bash
passwd='1234567'
/usr/bin/expect<<EOF
set time 30
spawn scp 1.sh root@192.168.32.65:/root
expect {
"*yes/no" { send "yes\r"; exp_continue }
"*password:" { send "$passwd\r" }
}
expect eof
EOF
/usr/bin/expect<<EOF
spawn ssh root@192.168.32.65
expect {
"*yes/no" { send "yes\r"; exp_continue }
"*password:" { send "$passwd\r" }
}
expect "*#"
send "who\r"
expect "*#"
send "date\r"
expect "*#"
send "exit\r"
interact
expect eof
EOF
shell 执行expect
最新推荐文章于 2023-10-31 21:42:17 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)