#!/bin/sh
df-H | grep -vE '^Filesystem|tmpfs|cdrom'|
awk '{print $5" "$1}' while read output;
do
echo $output
usep=$(echo $output |awk '{print $1}'| cut -d'%'-f1)
partition=$(echo $output | awk '{print $2}')
if [#usep -ge 80]; then
echo 'running out of space
\"$partition($usep%)\'on $(hostname)as on $(date)"|mail -s"alert:almost out of disk space $ usep% [email protected]);
f1
Done;
运行脚本时出现以下错误。
line 6 Unexpected EOF WHILE LOOKING FOR MATCHING '"'
LINE 13 :syntax error : unexpected end of file:
答案1
ram,你应该仔细检查你的脚本。它包含许多拼写错误(f1 而不是 fi,引用错误)。
我是这样做的:sh 不再抱怨它,你必须自己检查它正在做它应该做的事情:
#!/bin/sh
df -H | grep -vE '^Filesystem|tmpfs|cdrom'| awk '{print $5" "$1}'
while read output;
do
echo $output
usep=$(echo $output |awk '{print $1}'| cut -d'%'-f1)
partition=$(echo $output | awk '{print $2}')
if [#usep -ge 80]; then
echo "running out of space \"$partition($usep%)\"on $(hostname)as on $(date)"|mail -s"alert:almost out of disk space $ usep% [email protected]);"
fi
done