[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 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可能执行不成功

再来一个expect脚本的更多相关文章

  1. Linux-expect脚本-编写一个expect脚本

    1.声明expect #!/usr/bin/expect -f 2.设置超时时间,获取参数 set ip [lindex $argv 0 ] //接收第一个参数,并设置IP set password ...

  2. 关于expect脚本输出的问题

    写了一个expect脚本 执行ssh命令远程登录 然后telnet另外一台机器 大致如下: #!/usr/bin/expect -f set timeout set port_type [lindex ...

  3. Linux中使用expect脚本实现远程机器自动登录_linux shell

    首先创建一个expect脚本ssh_expect,文件内容如下: #!/usr/bin/expect -f set hostname [lindex $argv 0] set user [lindex ...

  4. Linux 下 expect 脚本语言中交互处理常用命令

    Linux 下 expect 脚本语言中交互处理常用命令 1. #!/usr/bin/expect 告诉操作系统脚本里的代码使用那一个 shell 来执行.这里的 expect 其实和 Linux 下 ...

  5. shell脚本通过expect脚本实现自动输入密码(使用expect)

    背景:在远程文件下载时,需要输入对方的服务器密码,shell不支持交互输入内容,可以用下面两种方式实现   一.在shell脚本中嵌入expect来实现密码输入 expect是一个自动交互功能的工具. ...

  6. shell脚本通过expect脚本实现自动输入密码

     背景:在远程文件下载时,需要输入对方的服务器密码,shell不支持交互输入内容,可以用下面两种方式实现   一.在shell脚本中嵌入expect来实现密码输入 expect是一个自动交互功能的工具 ...

  7. 容易忽略的expect脚本问题,暗藏的僵尸进程,wait命令不要漏掉

    问题描述 前几天有个小需求,用到expect脚本去循环的发送一些数据,主要问题代码如下: #! /usr/bin/expect while {true} { set timeout 60 spawn ...

  8. 分发系统介绍、expect脚本远程登录、expect脚本远程执行命令、expect脚本传递参数

    7月19日任务 20.27 分发系统介绍20.28 expect脚本远程登录20.29 expect脚本远程执行命令20.30 expect脚本传递参数 20.27 分发系统介绍 公司业务逐渐扩大时, ...

  9. expect脚本同步文件、expect脚本指定host和要同步的文件、构建文件分发系统、批量远程执行命令

    7月20日任务 20.31 expect脚本同步文件20.32 expect脚本指定host和要同步的文件20.33 构建文件分发系统20.34 批量远程执行命令扩展:shell多线程 http:// ...

随机推荐

  1. Servlet3.0使用@WebServlet注解配置问题记录

    文档说@WebServlet的配置属性都是可选的,不是必需的. 经实践,将一个Servlet配置成load-on-startup的Servlet时,若只添加loadOnStartup属性,该Servl ...

  2. [Functional Programming ADT] Create State ADT Based Reducers (applyTo, Maybe)

    The typical Redux Reducer is function that takes in the previous state and an action and uses a swit ...

  3. SpringMVC请求参数接收总结

    前提 在日常使用SpringMVC进行开发的时候,有可能遇到前端各种类型的请求参数,这里做一次相对全面的总结.SpringMVC中处理控制器参数的接口是HandlerMethodArgumentRes ...

  4. ubuntu14.04无法连接有线连接问题

    在windows系统下关闭有线网卡的关机,自动唤醒功能即可

  5. Hibernate 使用log4j输出日志

      jar包不能少:F:\jars\slf4j-api-1.7.5.jar   F:\strutsWsold\slf4j-1.7.5\slf4j-1.7.5\slf4j-log4j12-1.7.5.j ...

  6. sql server 使用for xml path 将1列多行转换为字符串连接起来

    create table tb ([id] )) insert into tb ,'aa' union all ,'bb' union all ,'cc' union all ,'dd' union ...

  7. Docker运行报Cannot connect to the Docker daemon错误

    核心问题所在:权限不足 操作docker命令提示:Cannot connect to the Docker daemon 请切换管理员权限,root权限,root安装的一般的用户访问会存在此问题.

  8. SSL and SSL Certificates Explained

    Secure Sockets Layer (SSL) and Transport Layer security (TLS ) are protocols that provide secure com ...

  9. 如何给app客户端进行埋点?

    1.什么是数据埋点? 当一款app开发完成后,一定需要查看数据,来分析用户访问量,点击量,转化率等等指标.想要查看数据,就得先做好数据埋点 注:html和app数据埋点的方式不同 2.常用app数据分 ...

  10. mybatis开发流程,增删改查

    一.开发流程 1)引jar包 //mybatis_core mybatis3.4core\asm-5.2.jar mybatis3.4core\cglib-.jar mybatis3.4core\co ...