有人可以帮助/纠正我编写一个 shell 脚本吗,这就是我想要做的
- 获取网页内容
- 比较内容
- 如果内容相同则返回0
- 如果不返回 2
这是我的代码
for cluster in $CLUSTERS
do
for applis in $(eval echo \$${cluster}_APPLIS)
do
CONTENT=$(wget -q -O - "http://$server/$applis")
if [ "$CONTENT" -eq 1 ]
then
exit_code=0
else
exit_code=2
fi
done
done
[[ -z "$error_server" ]] && error_server="aucune"
case $exit_code in
"2")
echo "CRITICAL - App Version Mismatch"
exit 2
;;
"1")
echo "WARNING - instance(s) indisponible(s)"
exit 1
;;
"0")
echo "OK - All apps have the save version"
exit 0
;;
*)
echo "CRITICAL - there's something wrong with this script ..."
exit 2
;;
esac
任何帮助或建议将不胜感激
问候工厂