我想连接从脚本收到的所有输出并通过一封电子邮件发送。这是我尝试过的方法,但它最终导致我的收件箱收到垃圾邮件。 :)
for f in $(ls "/vz/root") ;do
if [ -d "/vz/root/$f/var/lib/somesoftware" ]; then
if [ -f "/vz/root/$f/etc/network/interfaces" ];then
echo "Some program exist" $(grep address "/vz/root/$f/etc/network/interfaces")| mail -s "Subject" -r [email protected]
fi
fi
done
答案1
只需更改电子邮件正文的提取位置(并且不要解析ls
):
for f in /vz/root/*; do
if [ -d "$f/var/lib/somesoftware" ]; then
if [ -f "$f/etc/network/interfaces" ];then
echo "Some program exist" $(grep address "$f/etc/network/interfaces")
fi
fi
done | mail -s "Subject" -r [email protected]