shell下一个简单的程序
2007-06-17 14:11
127 查看
#! /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
以上程序注意两点
第一:!=前后都要用空格;
第二:`与‘的区别;
# 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
以上程序注意两点
第一:!=前后都要用空格;
第二:`与‘的区别;
相关文章推荐
- 使用管道实现简单的CMD后门程序,并转化为Shellcode
- ubuntu下一个开发环境安装的shell程序
- Linux下一个简单的Shell登陆界面系统
- 简单的shell程序
- 用shell写个简单的log监控程序
- 一个简单的shell程序
- 最简单的makefile和最简单的shell程序
- 一个简单的模拟shell的程序
- 用C语言编写一个Linux下的简单shell程序
- shell脚本程序的简单介绍及应用
- 一个简单的shell脚本编写的GUI程序
- 用shell编写的简单密码加密程序,涉及到ASCII与字符的相互转换,以及命令结果输出到变量
- 用shell写个简单的log监控程序
- linux下一个简单的TCP通信程序——客户端向服务端发送任意字符串
- 简单shell expect程序
- 最简单的makefile和最简单的shell程序
- 工作中一个简单的shell程序
- 一个简单的shell脚本程序(运用expr命令)
- 用C语言编写一个Linux下的简单shell程序
- 自己动手写一个简单的Shell之二:运行程序