场景

expect命令用于任何自动化互动的过程。

  • send – 发送字符串到进程
  • expect – 等待来自进程的特定的字符串
  • spawn – 启动命令

 

安装

expect一开始100%不存在, 手动执行yum安装

yum install expect

 

 

使用入门

假如有文件如下 /tmp/helloworld.exp

expect "hello" {
  send "world\n"
}

执行 expect  /tmp/helloworld.exp

将会进入交互模式, 直到你按了hello+换行后,输出world 再退出交互模式.

参考

6个Expect脚本示例==>https://blog.csdn.net/robertsong2004/article/details/38983259

相关文章:

  • 2022-12-23
  • 2022-02-12
  • 2022-12-23
  • 2022-12-23
  • 2021-07-15
  • 2021-10-20
  • 2021-06-04
  • 2022-12-23
猜你喜欢
  • 2021-11-06
  • 2022-12-23
  • 2021-09-05
  • 2022-12-23
  • 2021-08-18
  • 2021-12-14
  • 2021-04-15
相关资源
相似解决方案