这个小脚本可以检测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
windfly3166 于 2007-10-11 12:34:47发表:
瞧瞧,不明白这东西
Hbhmycg 于 2007-10-07 13:04:35发表:
路过
奶茶dsk 于 2007-10-07 12:40:31发表:
嘿嘿,正研究中。。。。。。:0L
gxf 于 2007-10-07 12:37:01发表:
好好学习下:0Q
奶茶dsk 于 2007-10-07 12:35:57发表:
呵呵,一针见血呀。。。。
gxf 于 2007-10-07 12:34:10发表:
SHELL编程,关键是弄清楚几个程序流程控制结构,但最基础的当然还是
SHELL命令本身,语法固然掌握好了,没有指令还是徒然!
支持……netstat用的还是比较多滴