[root@jenkins scripts]# cat expect_test1205.sh
#!/usr/bin/expect
##############################################################
# File Name: expect_test1205.sh
# Version: V1.
# Author: gaobo
# Organization: @qq.com
# Created Time : -- ::
# Description:
##############################################################
spawn ssh [email protected] uptime expect "*yes/no*"
send "yes\r"
expect "*password*" send "123456\r" expect eof
关键是执行:expect expect_test1205.sh
执行用expect命令.直接sh可能执行不成功