-1
因此,我正在运行下面的shellcript,并且在意外令牌'done'附近收到错误语法错误。它有什么问题?我错过了什么?运行脚本时意外令牌“完成”附近的语法错误
#!/bin/sh
df -H | grep -vE '^Filesystem|tmpf|cdrom' | awk ' {print $5 " " $6}' | while read output
do
echo $output
usep=$(echo $output | awk '{print $1}' | cut -d'%' -f1)
echo $usep
partition=$(echo $output | awk '{print $2}')
if [ $usep -ge 90 ]; then
echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date) : $usep%" |
mail -s "Alert: Critical Almost out of disk space $partition $usep%"
[email protected]
fi
if [ $usep -ge 5 ]; then
echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date) : $usep%" |
mail -s "Alert: Warning Almost out of disk space $partition $usep%" [email protected]
fi
done
@Carpetsmoker脚本正常工作由于管道不能以'结束'|',这样的行会自动继续。 – chepner 2014-08-27 14:56:19
你的脚本看起来不错;你如何运行它?在什么系统上?用哪个shell? ...这个问题最初被标记为'python',你使用Python来运行一个shell脚本吗?这显然是错误的... – Carpetsmoker 2014-08-27 14:59:39
无法重现,尽管你应该在''[']'中引用参数扩展,并且你可能想验证这些值实际上是整数。 – chepner 2014-08-27 15:01:00