当前位置:网站首页>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
边栏推荐
- Flask框架——Flask-WTF表单:文件上传、验证码
- HCIA experiment (07) comprehensive experiment
- Learn NLP with Transformer (Chapter 2)
- Learn NLP with Transformer (Chapter 4)
- Digital twin everything can be seen | connecting the real world and digital space
- 上周热点回顾(7.18-7.24)
- Flask framework - Message flash
- [树] 100. 相同的树
- Learn NLP with Transformer (Chapter 3)
- How to notify users of wechat applet version update?
猜你喜欢
随机推荐
[flask advanced] combined with the source code, explain the operation mechanism of flask (in and out of the stack)
三万字速通Servlet
哥廷根大学提出CLIPSeg:一个使用文本和图像prompt能同时作三个分割任务的模型
MySQL advanced statement (I) (there is always someone who will make your life no longer bad)
SQL语言(一)
[high concurrency] how to realize distributed flow restriction under 100 million level traffic? You must master these theories!!
Learn NLP with Transformer (Chapter 6)
Nb-iot control LCD (date setting and reading)
MySQL | GROUP_CONCAT函数,将某一列的值用逗号拼接
学习路之PHP--Phpstudy 提示 Mysqld.Exe: Error While Setting Value ‘NO_ENGINE_SUBSTITUTION 错误的解决办法
How to optimize the performance when the interface traffic increases suddenly?
Google Earth Engine——统计逐年土地分类的频率
HCIP(12)
HDD Hangzhou station full experience
【高并发】如何实现亿级流量下的分布式限流?这些理论你必须掌握!!
JS 将伪数组转换成数组
BGP联邦实验
tensorflow入门
[flask advanced] deeply understand the application context and request context of flask from the source code
Leetcode 560 prefix and + hash table








