本文共 1357 字,大约阅读时间需要 4 分钟。
#!/bin/bash
#program:Usingtostudythe[if...then...fi]program#dsk2007/10/83:00#content:Iwillusingthisprogramtoshowyousevices#1.printtheprogram''sworkinyourscreenecho "Now,the service of your Linux system will be detect!"echo "The www,ftp,ssh,and sendmail pop3 will be detect!"echo ""#2.wwwwww=netstat -ntlp | awk '{print $4}' | grep :80$
if [ "$www" != "" ]; thenecho $wwwecho "WWW is runing"elseecho $wwwecho "WWW is NOT runing"killall -9 httpd/usr/sbin/apachectl start#service httpd startfi#3.ftpftp=netstat -an | grep LISTEN | grep :21
if [ "$ftp" != "" ]; thenecho $ftpecho "FTP is runing "elseecho "FTP is not runing"killall -9 vsftpd#service vsftpd start/etc/init.d/vsftpd startfi#4.sshssh=netstat -ntlp | awk '{print $4}' | grep :22$
#ssh=netstat -an | grep LISTEN | grep :22
if [ "$ssh" != "" ]; thenecho $sshecho "SSH is running"elseecho "SSH is not running"fi#5.sendmail pop3smtp=netstat -an | grep LISTEN | grep :25
pop3=netstat -an | grep LISTEN | grep :110
if [ "$smtp" != "" ] && [ "$pop3" != "" ]; thenecho "Send mail is OK!" elif [ "$smtp" != "" ] && [ "$pop3" = "" ]; then
echo " Send mail have some problems of your pop3!"elif [ "$smtp" = "" ] && [ "$pop3" != "" ]; thenecho "Send mail have so me problems of your smtp!"elseecho "Send mail is NO Trunning!"fi转载于:https://blog.51cto.com/yanny/2091683