再来一个expect脚本

[root@jenkins scripts]# cat expect_test1205.sh
#!/usr/bin/expect
##############################################################
# File Name: expect_test1205.sh
# Version: V1.0
# Author: gaobo
# Organization: 641627690@qq.com
# Created Time : 2017-12-05 22:40:08
# Description:
##############################################################
spawn ssh root@10.0.0.51  uptime

expect "*yes/no*"
send "yes\r"
expect "*password*"

send "123456\r"

expect eof

 

关键是执行:expect expect_test1205.sh   

 

执行用expect命令.直接sh可能执行不成功

posted @ 2017-12-05 22:52  滴滴滴  阅读(210)  评论(0编辑  收藏  举报