LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1855|回复: 26

请帮我看看这些错误(重复,已合并)

[复制链接]
发表于 2003-5-17 12:51:50 | 显示全部楼层 |阅读模式
我按照南北兄的做法。在终端输入了。
set -o ignoreeof
为什么提示:
变量必须以一个letter开始。
发表于 2003-5-17 13:41:01 | 显示全部楼层
???不就是禁止用CTRL+D退出终端的吗?
把原文提示帖出来!;)
 楼主| 发表于 2003-5-18 00:15:19 | 显示全部楼层

为什么这样会出现错误?

我的程序是:
#if($#!=1)then
echo You must input the month and years
echo $#
else
if($2! "'*-*-*")then
echo Your years format is not right.
endif
endif
为什么提示第四行有错误?
/home/st18xx/st1866/mycal: line 4: syntax error near unexpected token `else'
/home/st18xx/st1866/mycal: line 4: `else'
 楼主| 发表于 2003-5-18 00:23:54 | 显示全部楼层

请帮我看看这些错误

我的SHELL是bash.程序如下:
if($#!=1)
then
echo You must input the month and years
echo $#
else
if($2! "'*-*-*")then
echo Your years format is not right.
fi
fi
为什么运行后会出现:
/home/st18xx/st1866/mycal: 0!=1: command not found
/home/st18xx/st1866/mycal: !: command not found
发表于 2003-5-18 00:26:26 | 显示全部楼层
逻辑上没什么错误,你的书写格式让人看了有些乱!
#
if ($# !=1) then
echo You must input the month and years
echo $#
else
if ($2 ! "*-*-*") then
echo Your years format is not right.
endif
endif
改成这样你运行试试.我不太懂CSH/TCSH,;)
这位兄弟,你发的帖子着实不好回答,
1,编写脚本是,第一行首先要声明你的脚本需要哪个shell解释器进行解释,如:#!/bin/sh, #!/bin/bash,#!/bin/csh,# (TCHS的第一行只有一个字符,而且必须是#)
2,任何语句,如if-then结构的语句,他们之间需要空格的,而你的从不留空格,那你让shell如何解释??? 如:if command[对]和ifcommand[错]
3,建议你先看看指定的入门帖子.OK?
4,谢谢
发表于 2003-5-18 00:36:09 | 显示全部楼层
1,空格
2,在bash中的控制结构是:
if 空格 表达式1
  then
    command1
  elif 空格 表达式2
  then
    command2
  else
    command3
fi
 楼主| 发表于 2003-5-18 00:58:52 | 显示全部楼层
已经改成这样了
if $#! =2
then
echo You must input the month and years
elif $2! ~"200*"
then
echo Your years format is not right.
fi
但还是提示同样的错误.
发表于 2003-5-18 01:00:49 | 显示全部楼层
判断的要用[   ]括起来。
发表于 2003-5-18 01:03:56 | 显示全部楼层
这为兄弟......故意的吧!
 楼主| 发表于 2003-5-18 01:05:31 | 显示全部楼层
版主兄.你要我看入门贴.我哪会不看?我不是那么笨,我也想尽快学会.问题是入门贴也不是很容易理解的.
比如南北兄的那句开关
set -o ingnoreeof
到现在我都不明白为什么我运行的就是不行?可能是各个shell不同吧.
现在我已经改成bash了.但好像bash不可以设置setenv .
您的程序我用了.同样的错误提示啊.
我一急之下可能会发了同样的贴子.很抱歉.
每次我发贴你都很快就回复.
非常感谢您的热心帮忙.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表