#发送邮件函数
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
function
send_mail(){
#定义邮件发送列表
maillist=(
zhengwei.liu@xxx
xiaogang.yang@xxx
sundy.she@xxx
)
#根据不同的函数参数,发送不同的邮件
if
[
"$1"
==
"gateway"
];
then
for
mail
in
${maillist[*]};
do
echo
"无法ping通网关,请检查网络"
| mail -s
"PI(10.78.1.122)网络故障"
$mail
done
elif
[
"$1"
==
"change"
];
then
for
mail
in
${maillist[*]};
do
mail -s
"$VIP发生切换"
$mail <
/tmp/VIP_qiehuan
.txt
done
fi
}
|
注:$1为函数的参数,不是脚本的参数
本文转自激情燃烧的岁月博客51CTO博客,原文链接http://blog.51cto.com/liuzhengwei521/2083282如需转载请自行联系原作者
weilovepan520