请教一段shell脚本

[复制链接]
查看11 | 回复3 | 2009-6-9 09:32:44 | 显示全部楼层 |阅读模式
#!/bin/csh
set currenttime = `date +%H`
echo "$currenttime"
if [ "$currenttime" == "08" ]
then

echo "Begin parser bindataFile file------------------------"

echo "Parser bindataFile file End------------------------"

else

echo "time is not match"
fi
这段脚本有问题么,我在unix下测试总时报错
08
Missing ]
修改完了还是报一样的错误
test.sh
09
Missing ]
如果用bash,就打印不出来了echo "$currenttime"
ksh也打印不出来。
去掉set,cshell报错,未定义的变量。
用bash一样
.//test.sh: line 2: currenttime: command not found

回复

使用道具 举报

千问 | 2009-6-9 09:32:44 | 显示全部楼层
if [ "$currenttime" == "08" ] 这种写法不对。应该是这么写if [ "$currenttime"-eq"08" ]或者是 if [ "$currenttime" = "08" ]...
回复

使用道具 举报

千问 | 2009-6-9 09:32:44 | 显示全部楼层
if [ "$currenttime" == "08" ]写为:if [ "$currenttime" = "08" ]...
回复

使用道具 举报

千问 | 2009-6-9 09:32:44 | 显示全部楼层
去掉set ......不是说用bash吗? - -! 我这都没问题,你等高人吧...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行