我正在尝试使用mailx通过外壳脚本发送电子邮件。
Message=<HTML><BODY><p>FINISHED</p></BODY></HTML>
[email protected];[email protected]
Recipients=$(echo "${Recipients}" | sed "s/;/ /g")
echo "Recipients: ${Recipients}"
mailx -s "Ingestion Report ${EXT1}. $( echo "\nContent-Type: text/html")" "${Recipients}" < $MESSAGE
我的问题是我试图将以分号分隔的列表更改为以空格分隔的列表,因为我被告知那是mailx所需要的。
但是,回复是:
sh: [email protected]: not found
我在做什么错?谢谢。
分号是命令分隔符,因此您必须从以下位置更改定义Recipients
的方式:
[email protected];[email protected]
收件人:
Recipients="[email protected];[email protected]"
引用该值可防止将;
解释为命令分隔符。
或者,您只能首先正确定义Recipients
:
Recipients="[email protected] [email protected]"
或者如果出于某种原因而无法控制,则可以放弃sed
呼叫并直接执行:
mailx ... ${Recipients/;/ }