Procmail deleting body











up vote
1
down vote

favorite












I have a procmail recipe which sends the body of a mail to a script. Works well but procmail then sends the mail without the body to my default folder.



:0
* ^Subject.*Telemetry rotate$
{
:0 bf
! `/usr/bin/php -f /path/to/script/script.php`
}


How can I have procmail send the body to my script without deleting it or send a copy to a folder and then delete the original.










share|improve this question
























  • Do the backticks work like a command substitution in the procmail config? I can't remember... Why would you want to use a command substitution there?
    – Kusalananda
    yesterday










  • As far as I can (also) remember the backticks serves to "escape" the command
    – Danny
    yesterday










  • The ! forwards the mail to the address that the PHP script outputs. That's what the ! at the start does. Is this what you intend? Did you intend to use | instead? Check the promailrc manual...
    – Kusalananda
    yesterday










  • I would regard it as surprising but not necessarily a bug that you can use the f flag with an ! action. This is a corner case I have never seen before. I'm pretty sure the recipe doesn't do at all what you want; but your question really should spell out more explicitly what you do want. The idea that backticks "escape" a command is certainly nonsense.
    – tripleee
    yesterday










  • yes, I want to pass the body to a script but also want a copy/original to be passed/sent to a folder for record purposes
    – Danny
    17 hours ago















up vote
1
down vote

favorite












I have a procmail recipe which sends the body of a mail to a script. Works well but procmail then sends the mail without the body to my default folder.



:0
* ^Subject.*Telemetry rotate$
{
:0 bf
! `/usr/bin/php -f /path/to/script/script.php`
}


How can I have procmail send the body to my script without deleting it or send a copy to a folder and then delete the original.










share|improve this question
























  • Do the backticks work like a command substitution in the procmail config? I can't remember... Why would you want to use a command substitution there?
    – Kusalananda
    yesterday










  • As far as I can (also) remember the backticks serves to "escape" the command
    – Danny
    yesterday










  • The ! forwards the mail to the address that the PHP script outputs. That's what the ! at the start does. Is this what you intend? Did you intend to use | instead? Check the promailrc manual...
    – Kusalananda
    yesterday










  • I would regard it as surprising but not necessarily a bug that you can use the f flag with an ! action. This is a corner case I have never seen before. I'm pretty sure the recipe doesn't do at all what you want; but your question really should spell out more explicitly what you do want. The idea that backticks "escape" a command is certainly nonsense.
    – tripleee
    yesterday










  • yes, I want to pass the body to a script but also want a copy/original to be passed/sent to a folder for record purposes
    – Danny
    17 hours ago













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have a procmail recipe which sends the body of a mail to a script. Works well but procmail then sends the mail without the body to my default folder.



:0
* ^Subject.*Telemetry rotate$
{
:0 bf
! `/usr/bin/php -f /path/to/script/script.php`
}


How can I have procmail send the body to my script without deleting it or send a copy to a folder and then delete the original.










share|improve this question















I have a procmail recipe which sends the body of a mail to a script. Works well but procmail then sends the mail without the body to my default folder.



:0
* ^Subject.*Telemetry rotate$
{
:0 bf
! `/usr/bin/php -f /path/to/script/script.php`
}


How can I have procmail send the body to my script without deleting it or send a copy to a folder and then delete the original.







procmail






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday









janos

7,11222347




7,11222347










asked yesterday









Danny

6710




6710












  • Do the backticks work like a command substitution in the procmail config? I can't remember... Why would you want to use a command substitution there?
    – Kusalananda
    yesterday










  • As far as I can (also) remember the backticks serves to "escape" the command
    – Danny
    yesterday










  • The ! forwards the mail to the address that the PHP script outputs. That's what the ! at the start does. Is this what you intend? Did you intend to use | instead? Check the promailrc manual...
    – Kusalananda
    yesterday










  • I would regard it as surprising but not necessarily a bug that you can use the f flag with an ! action. This is a corner case I have never seen before. I'm pretty sure the recipe doesn't do at all what you want; but your question really should spell out more explicitly what you do want. The idea that backticks "escape" a command is certainly nonsense.
    – tripleee
    yesterday










  • yes, I want to pass the body to a script but also want a copy/original to be passed/sent to a folder for record purposes
    – Danny
    17 hours ago


















  • Do the backticks work like a command substitution in the procmail config? I can't remember... Why would you want to use a command substitution there?
    – Kusalananda
    yesterday










  • As far as I can (also) remember the backticks serves to "escape" the command
    – Danny
    yesterday










  • The ! forwards the mail to the address that the PHP script outputs. That's what the ! at the start does. Is this what you intend? Did you intend to use | instead? Check the promailrc manual...
    – Kusalananda
    yesterday










  • I would regard it as surprising but not necessarily a bug that you can use the f flag with an ! action. This is a corner case I have never seen before. I'm pretty sure the recipe doesn't do at all what you want; but your question really should spell out more explicitly what you do want. The idea that backticks "escape" a command is certainly nonsense.
    – tripleee
    yesterday










  • yes, I want to pass the body to a script but also want a copy/original to be passed/sent to a folder for record purposes
    – Danny
    17 hours ago
















Do the backticks work like a command substitution in the procmail config? I can't remember... Why would you want to use a command substitution there?
– Kusalananda
yesterday




Do the backticks work like a command substitution in the procmail config? I can't remember... Why would you want to use a command substitution there?
– Kusalananda
yesterday












As far as I can (also) remember the backticks serves to "escape" the command
– Danny
yesterday




As far as I can (also) remember the backticks serves to "escape" the command
– Danny
yesterday












The ! forwards the mail to the address that the PHP script outputs. That's what the ! at the start does. Is this what you intend? Did you intend to use | instead? Check the promailrc manual...
– Kusalananda
yesterday




The ! forwards the mail to the address that the PHP script outputs. That's what the ! at the start does. Is this what you intend? Did you intend to use | instead? Check the promailrc manual...
– Kusalananda
yesterday












I would regard it as surprising but not necessarily a bug that you can use the f flag with an ! action. This is a corner case I have never seen before. I'm pretty sure the recipe doesn't do at all what you want; but your question really should spell out more explicitly what you do want. The idea that backticks "escape" a command is certainly nonsense.
– tripleee
yesterday




I would regard it as surprising but not necessarily a bug that you can use the f flag with an ! action. This is a corner case I have never seen before. I'm pretty sure the recipe doesn't do at all what you want; but your question really should spell out more explicitly what you do want. The idea that backticks "escape" a command is certainly nonsense.
– tripleee
yesterday












yes, I want to pass the body to a script but also want a copy/original to be passed/sent to a folder for record purposes
– Danny
17 hours ago




yes, I want to pass the body to a script but also want a copy/original to be passed/sent to a folder for record purposes
– Danny
17 hours ago










1 Answer
1






active

oldest

votes

















up vote
1
down vote













You have some errors here. The f flag says to replace the message with the output from the filter (though the b restricts this action to just the body). The braces are also superfluous here. So I'd go with



:0b
* ^Subject.*Telemetry rotate$
! `php -f /path/to/script/script.php`


if indeed the plan is to (1) pass the body to the PHP script, (2) capture the script's output (this is what the `backticks` do) and (3) forward the message to the address captured (that's wat the ! action does).



If your intention is merely to pass the body to your script, that would be



:0b
* ^Subject.*Telemetry rotate$
| php -f /path/to/script/script.php


maybe also with a c flag if you want to continue to process the message after this point.



You'll notice that I took out the hard-coded path /usr/bin; hardcoding the path makes the script less portable, and makes it impossible (or at least extremely cumbersome) to replace php with a wrapper for debugging purposes. I'd recommend to simply make sure you set up your PATH correctly in production.






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f489729%2fprocmail-deleting-body%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    You have some errors here. The f flag says to replace the message with the output from the filter (though the b restricts this action to just the body). The braces are also superfluous here. So I'd go with



    :0b
    * ^Subject.*Telemetry rotate$
    ! `php -f /path/to/script/script.php`


    if indeed the plan is to (1) pass the body to the PHP script, (2) capture the script's output (this is what the `backticks` do) and (3) forward the message to the address captured (that's wat the ! action does).



    If your intention is merely to pass the body to your script, that would be



    :0b
    * ^Subject.*Telemetry rotate$
    | php -f /path/to/script/script.php


    maybe also with a c flag if you want to continue to process the message after this point.



    You'll notice that I took out the hard-coded path /usr/bin; hardcoding the path makes the script less portable, and makes it impossible (or at least extremely cumbersome) to replace php with a wrapper for debugging purposes. I'd recommend to simply make sure you set up your PATH correctly in production.






    share|improve this answer



























      up vote
      1
      down vote













      You have some errors here. The f flag says to replace the message with the output from the filter (though the b restricts this action to just the body). The braces are also superfluous here. So I'd go with



      :0b
      * ^Subject.*Telemetry rotate$
      ! `php -f /path/to/script/script.php`


      if indeed the plan is to (1) pass the body to the PHP script, (2) capture the script's output (this is what the `backticks` do) and (3) forward the message to the address captured (that's wat the ! action does).



      If your intention is merely to pass the body to your script, that would be



      :0b
      * ^Subject.*Telemetry rotate$
      | php -f /path/to/script/script.php


      maybe also with a c flag if you want to continue to process the message after this point.



      You'll notice that I took out the hard-coded path /usr/bin; hardcoding the path makes the script less portable, and makes it impossible (or at least extremely cumbersome) to replace php with a wrapper for debugging purposes. I'd recommend to simply make sure you set up your PATH correctly in production.






      share|improve this answer

























        up vote
        1
        down vote










        up vote
        1
        down vote









        You have some errors here. The f flag says to replace the message with the output from the filter (though the b restricts this action to just the body). The braces are also superfluous here. So I'd go with



        :0b
        * ^Subject.*Telemetry rotate$
        ! `php -f /path/to/script/script.php`


        if indeed the plan is to (1) pass the body to the PHP script, (2) capture the script's output (this is what the `backticks` do) and (3) forward the message to the address captured (that's wat the ! action does).



        If your intention is merely to pass the body to your script, that would be



        :0b
        * ^Subject.*Telemetry rotate$
        | php -f /path/to/script/script.php


        maybe also with a c flag if you want to continue to process the message after this point.



        You'll notice that I took out the hard-coded path /usr/bin; hardcoding the path makes the script less portable, and makes it impossible (or at least extremely cumbersome) to replace php with a wrapper for debugging purposes. I'd recommend to simply make sure you set up your PATH correctly in production.






        share|improve this answer














        You have some errors here. The f flag says to replace the message with the output from the filter (though the b restricts this action to just the body). The braces are also superfluous here. So I'd go with



        :0b
        * ^Subject.*Telemetry rotate$
        ! `php -f /path/to/script/script.php`


        if indeed the plan is to (1) pass the body to the PHP script, (2) capture the script's output (this is what the `backticks` do) and (3) forward the message to the address captured (that's wat the ! action does).



        If your intention is merely to pass the body to your script, that would be



        :0b
        * ^Subject.*Telemetry rotate$
        | php -f /path/to/script/script.php


        maybe also with a c flag if you want to continue to process the message after this point.



        You'll notice that I took out the hard-coded path /usr/bin; hardcoding the path makes the script less portable, and makes it impossible (or at least extremely cumbersome) to replace php with a wrapper for debugging purposes. I'd recommend to simply make sure you set up your PATH correctly in production.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 22 hours ago

























        answered yesterday









        tripleee

        4,92911727




        4,92911727






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f489729%2fprocmail-deleting-body%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Accessing regular linux commands in Huawei's Dopra Linux

            Can't connect RFCOMM socket: Host is down

            Kernel panic - not syncing: Fatal Exception in Interrupt