【发布时间】:2013-08-24 00:52:46
【问题描述】:
我有一个有效的 procmail 配置。
这是 rc.filters :
:0 w :a.lock
* ^From:(.*\<)?(try@gmail\.com)\>
| $HOME/executable/a.out
此文件编译并运行,procmail 传递邮件, 并且可执行文件将内容写入输出文件。
#include <stdlib.h>
#include <iostream>
#include <fstream>
using namespace std;
int main(void)
{
ofstream myfile;
myfile.open ("output.txt");
string line;
while (getline(cin, line))
{
myfile << line << endl;
}
myfile.close();
return EXIT_SUCCESS;
}
问题是我需要一个带有内容的 cin 对象来传递 到Mimetic 库的构造函数。 我需要这个可执行文件才能工作:
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <mimetic/mimetic.h>
using namespace std;
using namespace mimetic;
int main(void)
{
ofstream myfile;
myfile.open ("output.txt");
MimeEntity me(cin);
const Header& h = me.header();
string subjectString = h.subject();
myfile << subjectString;
myfile << "Check";
myfile.close();
return EXIT_SUCCESS;
}
如果我收到一条名为 message.txt 的 Mime 消息并使用第二个代码执行以下操作:
cat message.txt | ./a.out
./a.out < message.txt
在这两种情况下,可执行文件都有效,我在 output.txt 中获得了主题
但是对于某些当它被调用并且通过 procmail 管道传输的内容时它不起作用,
我在 output.txt 中得到的只是“检查”,这意味着该文件
至少被调用了。
procmail.log 表明一切正常。
【问题讨论】:
-
@MichaelHampton 谢谢。是的,我确实在模仿网站上尝试过这个例子。同样的事情,当我从控制台尝试时效果很好,并且不适用于 procmail 管道。另一件事是,当我使用 shell 脚本尝试 procmail 时,它也可以工作。 procmail管道的方式......
-
您的
SHELL的价值是多少?如果将SHELL=/bin/sh添加到.procmailrc的顶部,情况会有所改善吗?