[英]How to cc a maillist in mailx command
I had prepared a cc maillist as below: 我准备了一个cc maillist如下:
/appl/tracker/TEST> more abc.maillist
xyz@yahoo.com, a123@gmail.com, abc@xyz.com
And a to maillist as below: 对于maillist如下:
/appl/tracker/TEST> more Servicedesk.maillist
123@gmail.com
My script is ab.sh
which will call the mailx
command and send an email. 我的脚本是
ab.sh
,它将调用mailx
命令并发送电子邮件。 This should send email to cc_list
keeping the id's in cc and to_list
placing the id provided in the list in to list. 这应该发送电子邮件到
cc_list
将id保存在cc和to_list
将列表中提供的id放入列表中。
/appl/tracker/TEST> more ab.sh
#!/bin/ksh
l_date=`date +%d%m%y`
CC_LIST=`cat /appl/tracker/TEST/abc.maillist`
TO_LIST=`cat /appl/tracker/TEST/Servicedesk.maillist`
MY_Q="'"
cc_list="$MY_Q$CC_LIST$MY_Q"
echo $cc_list
BODYFILE='Please find attached file having my details.Test mail'
echo $CC_LIST
echo $TO_LIST
mailx -s 'HI' -c $cc_list $TO_LIST <<-EOF
`echo $BODYFILE`
EOF
/appl/tracker/TEST>
Output: 输出:
There is an error being occured stating that there is an unbalanced "
. Can anyone please help me getting the solution for this. 发生错误表明存在不平衡的
"
。有人可以帮我解决这个问题。
I don't get that error message. 我没有收到该错误消息。 Are you sure you have pasted everything correctly?
你确定你已经正确粘贴了一切吗?
Anyway, an immediate problem is that you need to quote any variable interpolations. 无论如何,一个直接的问题是你需要引用任何变量插值。 It's not clear why you need variables for this at all, besides.
除此之外,还不清楚为什么你需要变量。 Here is a much simplified refactoring of your script.
这是一个非常简化的脚本重构。
#!/bin/sh
CC_LIST=`cat /appl/tracker/TEST/abc.maillist`
TO_LIST=`cat /appl/tracker/TEST/Servicedesk.maillist`
BODYFILE='Please find attached file having my details. Test mail'
echo "$CC_LIST"
echo "$TO_LIST"
echo "$BODYFILE" | mailx -s 'HI' -c "$CC_LIST" "$TO_LIST"
Variables must be double quoted to avoid expanding as list: 变量必须加双引号以避免扩展为列表:
mailx -s 'HI' -c "$cc_list" "$TO_LIST" <<-EOF
$BODYFILE
EOF
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.