Compare commits
2 Commits
2805e3d49f
...
845b012e72
Author | SHA1 | Date | |
---|---|---|---|
845b012e72 | |||
5225703c11 |
21
tutorials/basic/11-case.sh
Normal file
21
tutorials/basic/11-case.sh
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#Program:
|
||||||
|
# 这个shell脚本将介绍case的使用方法,输入1-3,三个数字,对不同的情况做不同的回应
|
||||||
|
|
||||||
|
echo -n "请输入一个数字 (1到3):"
|
||||||
|
read num
|
||||||
|
|
||||||
|
case $num in
|
||||||
|
1)
|
||||||
|
echo "你输入了 1"
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
echo "你输入了 2"
|
||||||
|
;;
|
||||||
|
3)
|
||||||
|
echo "你输入了 3"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "你输入的值不在范围"
|
||||||
|
;;
|
||||||
|
esac
|
27
tutorials/basic/12-port-check.sh
Normal file
27
tutorials/basic/12-port-check.sh
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#Program:
|
||||||
|
# 检查机器的开放服务,比如Http服务(80), https服务(443),ssh服务(22),邮箱服务(25)
|
||||||
|
#History:
|
||||||
|
# 2024/07/14 LouisFonda<yigencong@yahoo.com>
|
||||||
|
|
||||||
|
testfile=/dev/shm/netstat_checking.txt # 保存端口信息到内存
|
||||||
|
netstat -tunl > ${testfile}
|
||||||
|
|
||||||
|
echo -e "本机开通了如下服务"
|
||||||
|
|
||||||
|
testing=$(grep ":80" ${testfile})
|
||||||
|
if [ "${testing}" != "" ]; then
|
||||||
|
echo "http服务"
|
||||||
|
fi
|
||||||
|
testing=$(grep ":443" ${testfile})
|
||||||
|
if [ "${testing}" != "" ]; then
|
||||||
|
echo "https服务"
|
||||||
|
fi
|
||||||
|
testing=$(grep ":22" ${testfile})
|
||||||
|
if [ "${testing}" != "" ]; then
|
||||||
|
echo "ssh服务"
|
||||||
|
fi
|
||||||
|
testing=$(grep ":25" ${testfile})
|
||||||
|
if [ "${testing}" != "" ]; then
|
||||||
|
echo "email服务"
|
||||||
|
fi
|
Loading…
x
Reference in New Issue
Block a user