- 论坛徽章:
- 0
|
这是我做过的一个小程序,用于测试一些端口是否正常打开,或使用:
#!/bin/bash
#program: Using to study the [if ... then ... fi] program
#Written by: rcui
#date: 2006/08/29
#content: I will using this program to show your services
#1.print the program's work in you screen
echo "Now,the services 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 running"
else
echo "WWW is NOT running"
fi
#3.ftp
ftp='netstat -an | grep LISTEN | grep :21'
if [ "$ftp" != "" ]; then
echo "FTP is running"
else
echo "FTP is NOT running"
fi
#4.ssh
ssh='netstat -an | grep LISTEN | grep :20'
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 problem of your pop3"
elif [ "$smtp" = "" ] && [ "$pop3" != "" ]; then
echo "sendmail have some problem of your smtp"
else
echo "sendmail is NOT running"
fi
echo ""
exit 0 |
|