Test port port.sh
时间:2010-05-08 来源:hjjie2006
vi port.sh
#!/bin/bash
# program: Using to study the [if ... then ... fi] program
# Made by: VBird
# date: 2002/05/20
# content: I will using this program to show your services
# 1. print the program's work in your 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 :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 problem of your pop3"
elif [ "$smtp" = "" ] && [ "$pop3" != "" ]; then
echo "sendmail have some problem of your smtp"
else
echo "sendmail is NOT running"
fi
[test @test test]# sh port.sh Now, the services of your Linux system will be detect!
The www, ftp, ssh, and sendmail + pop3 will be detect!
# Made by: VBird
# date: 2002/05/20
# content: I will using this program to show your services
# 1. print the program's work in your 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 :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 problem of your pop3"
elif [ "$smtp" = "" ] && [ "$pop3" != "" ]; then
echo "sendmail have some problem of your smtp"
else
echo "sendmail is NOT running"
fi
[test @test test]# sh port.sh Now, the services of your Linux system will be detect!
The www, ftp, ssh, and sendmail + pop3 will be detect!
WWW is running
FTP is running
SSH is running
sendmail is OK!
Reprinted:VBird
相关阅读 更多 +
排行榜 更多 +