- 论坛徽章:
- 0
|
以下是port.sh的内容
#! /bin/bash
# program: Using to study the [if... then ...fi] program
# Written by :Beyond
# date: 2007/06/15
# content: I will be 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 proble of your smtp"
else
echo "sendmail is NOT running"
fi
然后运行后出现以下
Now, the services of your Linux system will be detect!
The www, ftp, ssh, and sendmail + pop3 will be detect!
port.sh: line 13: [: netstat -an|grep LISTEN|grep :80: unary operator expected
www is not running
port.sh: line 20: [: netstat -an|grep LISTEN|grep :21: unary operator expected
FTP is NOT running
port.sh: line 27: [: netstat -an|grep LISTEN|grep :22: unary operator expected
SSH is NOT running
port.sh: line 35: [: netstat -an|grep LISTEN|grep :25: unary operator expected
sendmail have some problem of your pop3 |
|