zl程序教程

您现在的位置是:首页 >  其它

当前栏目

再来一个expect脚本

脚本 expect
2023-09-11 14:20:31 时间
[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可能执行不成功