strange behaviour of procmail when piping content to c++ executable -
i have working procmail config.
rc.filters :
:0 w :a.lock * ^from:(.*\<)?(try@gmail\.com)\> | $home/executable/a.out
this file compiles , works, procmail delivers mail, , executable writes content output file.
#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; }
the problem need cin object content pass constructor of mimetic library. need executable work:
#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; }
if take mime message called message.txt , following second code :
cat message.txt | ./a.out ./a.out < message.txt
in both cases executable works , subject in output.txt
when invoked , content piped procmail doesn't work,
, in output.txt "check" means file @ least invoked.
the procmail.log states fine.
i don't know what's going on capture input std::cin
string , pass std::istringstream
constructed value mimeentity
. way can inspect input std::cin
while still having processed library:
std::istreambuf_iterator<char> begin(std::cin), end; std::string message(begin, end); out << "received >>>" << message << "<<<\n"; std::istringstream in(message); mimeentity me(in); // ...
Comments
Post a Comment