免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 15811 | 回复: 2
打印 上一主题 下一主题

unary operator expected问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-06-17 00:18 |只看该作者 |倒序浏览
以下是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

论坛徽章:
0
2 [报告]
发表于 2007-06-17 09:23 |只看该作者
注意!=前后都要有空格
还有注意单引号和`(tab键上面的那个)的区别

论坛徽章:
0
3 [报告]
发表于 2007-06-17 13:35 |只看该作者
原帖由 li2002 于 2007-6-17 09:23 发表
注意!=前后都要有空格
还有注意单引号和`(tab键上面的那个)的区别

谢谢,此问题已经解决!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP