命令输出我试着在主题庆典邮件:在主题
subj="hello from $(hostname -s) $(date)"
echo "data" | mail -s $subj [email protected]
发送邮件与mail
命令,与其他命令的输出,但我只得到主题(hello from
)的第一部分。
为什么?
命令输出我试着在主题庆典邮件:在主题
subj="hello from $(hostname -s) $(date)"
echo "data" | mail -s $subj [email protected]
发送邮件与mail
命令,与其他命令的输出,但我只得到主题(hello from
)的第一部分。
为什么?
你需要引用你的主题,如:
echo "data" | mail -s "$subj" [email protected]
如果不引用它,则mail
程序不会知道你的主题结束,将采取先“字”(hello
)作为主题和其他所有内容作为地址。
总的来说,总是引用你的变量是一个好习惯。
/youScriptOrOutput.sh | mail -s“Subject from host $(hostname -s)$(date)”[email protected]