#!/bin/bash
read -p "Input prot" port
#Is Number
echo $port |grep -q '[0-9]'
if [ $? -ne 0 ];then
echo "Illegal character(Not Number)!!!"
exit
fi
#Is Illegal
if [ -z $port ];then
echo "Effective range(1-65535)"
exit
elif [ $port -lt 1 -o $port -gt 65535 ];then
echo "Port out of range"
exit
fi
ss -nltp|grep -qw $port
#Is Listening
if [ $? -eq 0 ];then
echo "$port is listening"
else
echo "$port is not listening"
fi
Qt开发 — 检查系统端口是否被监听
于 2022-05-25 11:18:35 首次发布