【发布时间】:2021-10-22 14:51:55
【问题描述】:
我在使用 mail 命令从 Linux 机器发送电子邮件时遇到问题。它不是像在正文中那样发送错误日志,而是以 .bin 格式作为附件发送。在少数情况下,它发送的是身体。以下是我尝试通过电子邮件作为正文发送的日志详细信息。是因为它作为.bin附件发送的日志中的“/”等特殊字符吗?我可以使用 sendmail 来解决这个问题,但我们想使用 mail 命令发送它。
原因:org.springframework.integration.MessagingException:上传文件时无法写入'/DBSInboundandOutbound/prod/outbound/DSP/PartsMaster/PartsMasterFull_NNANissanV5124_20211015071711.xml.gz.tmp' 原因:java.io.IOException :无法将“/DBSInboundandOutbound/prod/outbound/DSP/PartsMaster/PartsMasterFull_NNANissanV5124_20211015071711.xml.gz.tmp”重命名为/DBSInboundandOutbound/prod/outbound/DSP/PartsMaster/PartsMasterFull_NNANissanV5124_20211015071711.xml.gz'。服务器回复:550'PartsMasterFull_NNANissanV5124_20211015071711.xml.gz.tmp':无法重命名。 2021-10-15 02:01:49,342 错误 | dbs-intg-scheduler-18 | c.n.d.j.adapter.support.MDCFatalErrorChannelInterceptor | [DBS] 致命错误 [org.springframework.integration.MessageDeliveryException:文件错误处理消息 [/datapp/common/batch_datafile/parts/P-16/outComingFolder/PartsMasterFull_NNANissanV5124_20211015071711.xml.gz]] -org.springframework.integration.MessagingException : 无法写入 '/DBSInboundandOutbound/prod/outbound/DSP/PartsMaster/PartsMasterFull_NNANissanV5124_2021101507171 1.xml.gz.tmp' 同时上传文件
mContent=`cat $1`
msgimp=$2
mailsub=$3
monitor=$4
logname=$5
echo >> /datapp/common/operation_admin/monitor/monitor_log/$mailsub.txt
echo $mContent >> /datapp/common/operation_admin/monitor/monitor_log/$mailsub.txt
mail -s "[Prod] [$monitor] [$msgimp] [$mailsub] found in $logname log" -r "DBS Production
Alert <noreply@*******.com>" alert.*********.com <
/datapp/common/operation_admin/monitor/monitor_log/$mailsub.txt
rm -f /datapp/common/operation_admin/monitor/monitor_log/$mailsub.txt
【问题讨论】:
-
为什么要使用
$mContent变量?只需使用cat "$1" >> filename -
记得引用所有变量。