linux脚本检测端口,发个检测端口是否开启的小脚本!

发个检测端口是否开启的小脚本!

发布时间:2007-10-07 12:09:13来源:红联作者:奶茶dsk

这个小脚本可以检测WWW,ftp,ssh,sendmail + pop3服务是否开启:

#!/bin/bash

#program: Using to study the [ if ... then ... fi ] program

#dsk 2007/10/8 3:00

#content: I will using this program to show you sevices

#1. print the program's work in your screen

echo "Now, the service of your Linux system will be detect!"

echo "The www, ftp,ssh,and sendmail + pop3 will be detect!"

echo " "

#2. www

www='netstat -an|grep LISTEN|grep :80'

if [ "$www" != "" ]; then

echo "WWW is runing"

else

echo "WWW is NOT runing"

fi

#3. ftp

ftp='netstat -an|grep LISTEN|grep :21'

if [ "$ftp" != "" ]; then

echo "FTP is runing"

else

echo "FTP is not runing"

fi

#4. ssh

ssh='netstat -an|grep LISTEN|grep :22'

if [ "$ssh" != "" ];then

echo "SSH is running"

else

echo "SSH is not running"

fi

#5. sendmail + pop3

smtp='netstat -an|grep LISTEN|grep :25'

pop3='netstat -an|grep LISTEN|grep :110'

if [ "$smtp" != "" ] && [ "$pop3" != "" ]; then

echo "Sendmail is OK!"

elif [ "$smtp" != "" ] && [ "$pop3" = "" ]; then

echo "Sendmail have some problems of your pop3!"

elif [ "$smtp" = "" ] && [ "$pop3" != "" ]; then

echo "Sendmail have some problems of your smtp!"

else

echo "Sendmail is NOT running!"

fi

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值