shell习题第25题:判断是否开启web服务

【题目要求】

写一个脚本判断我的linux服务器是否开启web服务?监听80端口

【核心要点】

netstat -lntp | grep '80'

【脚本】

#!/bin/bash
n=`netstat -lntp | grep ':80' | wc -l`

if [ $n -eq 0 ]; then
    echo "It not listen port 80"
else
    ser=`netstat -lntp | grep ':80 ' | awk -F '/' '{print $NF}'`
    echo "It is listening port 80, and the server is $ser"
fi
原文地址:https://www.cnblogs.com/dingzp/p/10992051.html