Find the answer to your Linux question:
Results 1 to 2 of 2
I'm working on a CentOS 6.4 , gcc 4.4.7 I have a working procmail config. this is the rc.filters : Code: :0 w :a.lock * ^From:(.*\<)?(try<atSign>linuxforums\.org)\> | $HOME/executable/a.out this file ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jul 2013
    Posts
    3

    strange behaviour of procmail when piping content to c++ executable


    I'm working on a CentOS 6.4 , gcc 4.4.7
    I have a working procmail config.
    this is the rc.filters :

    Code:
    :0 w :a.lock
    * ^From:(.*\<)?(try<atSign>linuxforums\.org)\>
    | $HOME/executable/a.out
    this file compiles and works, procmail delivers the mail, and the executable writes the content to the output file.

    Code:
    #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 is I need a cin object with the content to pass to a constructor of the Mimetic library. I need this executable to work:

    Code:
    #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 I take a Mime message called message.txt and do the following with the second code :

    Code:
    cat message.txt | ./a.out
    Code:
    ./a.out < message.txt
    In both cases the executable works and I get the subject in an output.txt
    but for some when it is invoked and the content piped by procmail it doesn't work,
    and all I get in the output.txt is "Check" which means that the file was at least invoked.

    the procmail.log states that everything is fine.

    Thanks for helping!

  2. #2
    Just Joined!
    Join Date
    Jul 2013
    Posts
    3
    Quote Originally Posted by stasov View Post
    I'm working on a CentOS 6.4 , gcc 4.4.7
    I have a working procmail config.
    this is the rc.filters :

    Code:
    :0 w :a.lock
    * ^From:(.*\<)?(try<atSign>linuxforums\.org)\>
    | $HOME/executable/a.out
    this file compiles and works, procmail delivers the mail, and the executable writes the content to the output file.

    Code:
    #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 is I need a cin object with the content to pass to a constructor of the Mimetic library. I need this executable to work:

    Code:
    #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 I take a Mime message called message.txt and do the following with the second code :

    Code:
    cat message.txt | ./a.out
    Code:
    ./a.out < message.txt
    In both cases the executable works and I get the subject in an output.txt
    but for some when it is invoked and the content piped by procmail it doesn't work,
    and all I get in the output.txt is "Check" which means that the file was at least invoked.

    the procmail.log states that everything is fine.

    Thanks for helping!
    I got the following advise on StackOverFlow :
    This description implies that the pipe is not the problem. Instead, something in the program's environment is setup by procmail to put your MimeEntity off. I would check if MimeEntity uses some environment variables which are set up differently (e.g., the locale or the encoding), if there is a dependency on the user (e.g. run the program as the user procmail from the console), etc

    Any idea on how to check with which user is procmail running?
    or what are the environment variables of that user?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •