当前位置:网站首页>shell-第五章作业
shell-第五章作业
2022-07-25 10:28:00 【weixin_51808099】
- 使用case实现成绩优良差的判断
[[email protected] zuoye]# vim 5.1.sh
#1/bin/bash
read -p "please input your grade:" grade
case $grade in
8[5-9]|9[0-9]|100)
echo "A"
;;
7[0-9]|8[0-4])
echo "B"
;;
6[0-9])
echo "C"
;;
*)
echo "D"
esac
- for创建20用户
用户前缀由用户输入
用户初始密码由用户输入
例如:test01,test10
[[email protected] zuoye]# vim 5.2.sh
#!/bin/bash
a=0
for i in `seq 15`
do
read -p "please input your name :" name
if [ "$i -lt 10" ];then
useradd $name$a$i
passwd $name$a$i
else
useradd $name$i
passwd $name$i
fi
done
- for ping测试指网段的主机
网段由用户输入,例如用户输入192.168.2 ,则ping 192.168.2.10 — 192.168.2.20
UP: /tmp/host_up.txt
Down: /tmp/host_down.txt
[[email protected] zuoye]# vim 5.3.sh
#!/bin/bash
read -p "please input your IP: " IP
for i in `seq 120 130`
do
ping -c2 $IP.$i &>/dev/null
if [ $? -eq 0 ];then
echo $IP.$i >> ./host_up.txt
else
echo $IP.$i >> ./host_down.txt
fi
done
- 使用for实现批量主机root密码的修改
成功或失败都必须记录
提示:主机IP存放在一个文件中
SSH:实现公钥认证,执行远程中主机命令
实现公钥认证ssh-keygen 在用于管理的主上生成密钥对
ssh-copy-id -i 192.168.2.3
[[email protected] zuoye]# vim 5.4.sh
#!/bin/bash
for i in `grep ^1 hostip`
do
echo "you will change the [email protected]$i'passwq "
ssh $i passwd root
if [ $? -eq 0 ];then
echo "[email protected]$i'passwd was change" >> hps
else
echo "[email protected]$i'passwq is not change" >> hpf
fi
done
边栏推荐
- 我,AI博士生,在线众筹研究主题
- Visual thematic map of American airport go style: ArcGIS Pro version
- Flask框架——消息闪现
- txt转csv文件,隔行出现空行
- Redis sentry, high availability executor
- Code representation learning: introduction to codebert and other related models
- Learn NLP with Transformer (Chapter 1)
- SQL语言(三)
- 机智云物联网平台 STM32 ESP8266-01S 简单无线控灯
- 【Servlet】请求的解析
猜你喜欢

BeautifulSoup的一些用法

NB-IOT控制液晶屏(日期的设置与读取)

2021 CEC written examination summary

Learn NLP with Transformer (Chapter 8)

SQL语言(二)
![TPS calculation in performance test [Hangzhou multi tester] [Hangzhou multi tester _ Wang Sir]](/img/b2/7a6b99f0ec907b83ac58ed44b23062.png)
TPS calculation in performance test [Hangzhou multi tester] [Hangzhou multi tester _ Wang Sir]

UE4.26源码版学习广域网独立服务器时遇到的客户端运行黑屏问题

mysql高级语句(一)(总有一个人的出现,让你的生活不再继续糟糕)

Learn NLP with Transformer (Chapter 1)

【IJCAI 2022】参数高效的大模型稀疏训练方法,大幅减少稀疏训练所需资源
随机推荐
UE4.26源码版学习广域网独立服务器时遇到的客户端运行黑屏问题
How to notify users of wechat applet version update?
SQL语言(六)
数字孪生万物可视 | 联接现实世界与数字空间
STM32CubeMX学习记录--安装配置与使用
HCIA experiment (08)
tensorflow 调用多块GPU的一些错误
【域泛化】2022 IJCAI领域泛化教程报告
Reinforcement Learning 强化学习(四)
HCIA实验(06)
HCIA experiment (09)
HCIA experiment (06)
Learn NLP with Transformer (Chapter 7)
Reinforcement Learning 强化学习(三)
API supplement of JDBC
The idea has been perfectly verified again! The interest rate hike is approaching, and the trend is clear. Take advantage of this wave of market!
mysql事务是什么
How can you use unity without several plug-ins? Unity various plug-ins and tutorial recommendations
Learn NLP with Transformer (Chapter 4)
Learn NLP with Transformer (Chapter 2)