[英]print out variable in procmail
I have a procmail recipe to filter incoming mail such as below: 我有一个procmail配方来过滤收到的邮件,如下所示:
:0
*^Subject:.*(test)
* ? egrep -is -f /root/Procmail/whitelist.txt
{
:0 fwb
| formail -I ""
:0
myfolder/
}
The above recipe function is to filter out the body content of the email and forward that mail to myfolder. 上述配方功能是过滤掉电子邮件的正文内容并将该邮件转发给myfolder。 The problem is i have a variable that i want to put inside the body.
问题是我有一个变量,我想放在体内。
FROM_=`formail -c -x"From " \
| expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g' \
| awk '{ print $1 }'`
SUBJ_=`formail -c -x"Subject:" \
| expand \
| sed -e 's/ */ /g' \
| sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'`
This email body (together with the variable) should be forward to myfolder. 此电子邮件正文(连同变量)应该转发到myfolder。
I've try to echo the variable like this but still no use. 我试图像这样回应变量,但仍然没有用。
:0 fwb
echo "${SUBJ_}"
echo "{FROM_}"
Is the something wrong with my recipe?Can someone help me? 我的食谱有问题吗?有人能帮帮我吗?
You need to pipe into the shell script. 您需要管道进入shell脚本。 An action without a prefix saves to a folder named "echo", in your case.
在您的情况下,没有前缀的操作会保存到名为“echo”的文件夹中。
You were also lacking a dollar sign on the ${FROM_}
variable. 您还在
${FROM_}
变量上缺少美元符号。
:0 fwb
| ( echo "${SUBJ_}"; echo "${FROM_}" )
Your assignments could probably be optimized quite a bit. 您的作业可能会进行相当多的优化。 Piping
sed
to sed
or awk
is rarely necessary; 管道
sed
sed
或awk
很少是必要的; if sed
cannot handle what you want, then let awk
do it all. 如果
sed
无法处理你想要的东西,那么让awk
做到这一切。
FROM_=`formail -c -x"From " \
| expand \
| awk '{ gsub (/^[ ]*|[ ]*$/,""); print $1 }'`
SUBJ_=`formail -c -x"Subject:" \
| expand \
| sed -e 's/ */ /g' -e 's/^[ ]*//g' -e 's/[ ]*$//g'`
(Not sure why you would need expand
in there either, but I left it in just in case.) (不知道为什么你需要在那里
expand
,但为了以防万一我把它留下了。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.