惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog
A
About on SuperTechFans
Microsoft Security Blog
Microsoft Security Blog
Y
Y Combinator Blog
罗磊的独立博客
J
Java Code Geeks
人人都是产品经理
人人都是产品经理
MongoDB | Blog
MongoDB | Blog
The GitHub Blog
The GitHub Blog
G
Google Developers Blog
U
Unit 42
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - Franky
Jina AI
Jina AI
F
Fortinet All Blogs
H
Help Net Security
B
Blog RSS Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Last Week in AI
Last Week in AI
博客园 - 司徒正美
云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
C
Check Point Blog
GbyAI
GbyAI

博客园 - longbigfish

部署(https证书) https证书问题(本地) 参数更新 Ubuntu 24安装Neo4j详细教程 protect 紧急 手机 刷脏页的两种模式 python中的多线程陷阱与pytorch分布式执行机制 git之复合指令和submodule rpc编程示例 mpi编程 cifs远程挂载 cifs挂载远程文件出现 No such device or address错误 longtable 跨越多个页面时,如何在跨页时自动断行并加上横线及去掉页眉 matplotlib中文显示-微软雅黑 latex编译过程-关于嵌入所有字体 python做图笔记 linux启动全过程 连接并同步windows下的git仓库 反向ssh
使用脚本进入一个命令行控制台,并预设执行的命令列表
longbigfish · 2019-04-01 · via 博客园 - longbigfish

参考1:https://codeday.me/bug/20170628/32557.html

参考2:https://avdeo.com/2009/08/14/spawn-expect-send-and-interact/

主要是使用Unix内置的expect程序。

在脚本之前  写 #!/usr/bin/expect 或 #!/usr/bin/expect -f 均表明该脚本使用expect执行。

expect可以识别spwn,expect,interact,send等命令,还有set promt等。

使用spwn命令启动一个外部程序。

使用expect等待将要出现的字符串,可以使用通配符,只有出现了匹配的字符串,才继续执行脚本中下一条命令。

使用send发送需要外部程序执行的命令。

man7上有详细介绍 http://man7.org/linux/man-pages/man1/expect.1.html