2008-4-24 10:16
胖胖猪
脚本
哪位好心大哥帮我看一下脚本吧,不知道对不对?
a=80
b=$(df -k|awk '{print $4}')
if[$b -gt $a]; then
/home/novots/dfcheck.sh
else
echo All filesystems are smaller than 80%
fi
我就是想当有大于80%的文件系统时,就执行dfcheck.sh这个脚本,可是运行之后,报错:0403-057 Syntax error at line 4 : `then' is not expected.
2008-4-24 10:24
老农
带行号列出来
2008-4-24 10:26
胖胖猪
promappbak:[/home/novots]#vi checkdf.sh
"checkdf.sh" 8 lines, 126 characters
a=80
b=$(df -k|awk '{print $4}')
if[$b -gt $a]; then
/home/novots/dfcheck.sh
else
echo All filesystems are smaller than 80%
fi
~
~
~
~
~
~
~
农哥,是这样吗
2008-4-24 10:29
smallflower
晕
:set nu
2008-4-24 10:30
sjhsjhqz
判断肯定有问题!
2008-4-24 10:32
胖胖猪
大哥,:set nu 是什么意识啊?
2008-4-24 10:33
胖胖猪
小弟shell基础不太好,呵呵
2008-4-24 10:44
sjhsjhqz
每行会带行号,你在VI试一下不就知道了么。
2008-4-24 10:45
胖胖猪
农哥,帮我看看吧
2008-4-24 12:08
老农
叫你干啥你怎么不听?
2008-4-24 12:11
老农
a=80
b=$(df -k|awk '{print $4}')
if[$b -gt $a]
then
/home/novots/dfcheck.sh
else
echo All filesystems are smaller than 80%
fi
2008-4-24 15:26
胖胖猪
像这样还不行啊
promappbak:[/home/novots]#vi checkdf.sh
"checkdf.sh" 7 lines, 131 characters
a=80
b=$(df -k|awk '{print $4}')
if[$b -gt $a]
then
/home/novots/dfcheck.sh
else
echo All filesystems are smaller than 80%
fi
~
~
~
~
2008-4-24 16:04
胖胖猪
还报这样的错误 0403-057 Syntax error at line 5 : `then' is not expected.
2008-4-24 17:35
luweinet
这个...%都没有去掉,你怎么比较?
另外你读出来的也是一个列,能和一个变量直接比较?
加入set -x
然后用循环慢慢折腾吧
[[i] 本帖最后由 luweinet 于 2008-4-24 19:58 编辑 [/i]]
2008-4-24 20:29
luweinet
df | grep ^/ | sed 's/\%//g' | awk '{if ($5 >= 80) system ("echo "$1)}{if ($5 < 80) print"file system "$6" is ok"}'
呃 linux上的结果,还是awk好玩
页:
[1]
Powered by Discuz! Archiver 5.5.0
© 2001-2006 Comsenz Inc.