当前位置:网站首页>Expect+sh realize automatic interaction
Expect+sh realize automatic interaction
2022-07-25 09:45:00 【clusters of stars ¹ ⁸⁹⁵】
1. sh command
2. expect command
2.1 install expect
sudo apt-get install expect
3. actual combat
3.1 expect+sh Realize batch automatic user creation
#!/bin/bash
#!/user/bin/expect
passwd=Fight666
list="username1 username2"
addgroup groupname1
for i in $list;
do
expect << EOF set timeout 10 spawn adduser $i expect "*password:" { send "$passwd\r"} expect "*password:" { send "$passwd\r"} expect "]:" { send "\r" } expect "]:" { send "\r" } expect "]:" { send "\r" } expect "]:" { send "\r" } expect "]:" { send "\r" } expect "*Y/n]" { send "y\r" } EOF
usermod -s /bin/bash -g groupname1 $i;
done
Reference link :
expect Usage introduction
Linux in EOF and Expect Detailed command
边栏推荐
- [gplt] 2022 popular lover (Floyd)
- OC -- category extension agreement and delegation
- Android & Kotlin : 困惑解答
- 初识Opencv4.X----为图像添加椒盐噪声
- @3-1 CCF 2020-09-1 scale detection point query
- Indexes, views and transactions of MySQL
- Preliminary understanding and implementation of wechat applet bottom navigation bar
- *7-1 CCF 2015-09-1 sequence segmentation
- [code source] a prime number of fun every day (BFS)
- OC--Foundation--字符串+日期和时间
猜你喜欢
随机推荐
UI - infinite rotation chart and column controller
【Android studio】批量数据导入到android 本地数据库
打造个人极限写作流程 -转载
yolov5实现小数据集的目标检测--kolektor缺陷数据集
main函数的一些操作
Customize the view to realize the background of redeeming lottery tickets [elementary]
cell的定义
[code source] National Railway
Swagger2 shows that there is a problem with the get interface, which can be solved with annotations
A picture explains SQL join left and right
换电脑后如何配置SSH
matlab如何导入大量数据
降低程序空间复杂度的一些技巧
初识Opencv4.X----图像直方图匹配
初识Opencv4.X----图像模板匹配
Why use json.stringify() and json.parse()
一张图讲解 SQL Join 左连 又连
[code source] daily one question three paragraph
初识Opencv4.X----图像直方图绘制
本地存储待办事项(在待办事项上进行改进)



![[code source] I have a big head for a problem every day](/img/02/cb083e247fe1f8374020db4b803758.png)





