user=root
ip=1.1.1.1
passwd=1111
expect<<!
spawn ssh $user@$ip
expect {
"(yes/no)?" {
send "yes\n"
expect "assword:"
send "$passwd\n"
}
"assword:" {
send "$passwd\n"
}
}
expect "#"
send "sh /root/sbin/get_master.sh\r"
send "exit\r"
expect eof
!
linux 使用expect
最新推荐文章于 2023-11-16 14:07:56 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)