procmail
[Top] [All Lists]

Re: Q on procmail to perl pipe

1999-03-24 00:22:00
"Walter" <walter(_at_)tscinternet(_dot_)com> writes:
I have this perl script...

==============CODE

#! usr/local/bin/perl5 -w

Shouldn't that be either
        #!/usr/local/bin/perl5 -w
or      #! /usr/local/bin/perl5 -w

(Some older systems required the space)


print '==============================', "\n";

Uh, 
        print "==============================\n";


open(LOG, ">>perl.out") or die;

You might as well make the error message useful:

        open(LOG, ">>perl.out") or die "$0: Unable to open perl.out: $!";


      while(<STDIN>)
      {
              print LOG '===============================', "\n";

see above

              print LOG @_, "\n\n";

The "while(<FOO>)" construct places the line read into $_, not @_.
Since you didn't chop() or chomp() the line, the two extra newlines will
result in triple spacing in the logfile.  Assuming you want(?) that:

        print LOG $_, "\n\n";


...
## -- Testing
       :0
       * ^TO()perl(_at_)tscinternet(_dot_)com
       * HB ?? ? "$HOME/vmail/perl/perl test.pl"

Does the name of the script really have a space inside it?  Blech.  If
that's true, make sure the script is executable.  Can you run it from
outside of procmail?

Also, the "HB ??" is superfluous, as command conditions receive the
entire message on stdin, regardless of the presence or abscence of the
H or B recipe flags.  (The "HB ??" syntax _does_ change what the
command see.  It's just that it 'changes' it to the already-in-effect
default in this case.)  So:

        * ? "$HOME/vmail/perl/perl test.pl"


       | true

The final gotcha is that since the 'true' command doesn't read its
stdin, procmail will think something is wrong when it isn't able to
write the entire message down the pipe to 'true', cause it to treat the
entire recipe as a failure.  If you just want to the test.pl on the
message and ignore it's exit status, just make it the condition and
don't put the 'w' or 'W' flags on the recipe.  If it might not read the
entire message, add the 'i' flag.

        :0
        * ^TO()perl(_at_)tscinternet\(_dot_)com
        |"$HOME/vmail/perl/perl test.pl"


Philip Guenther

<Prev in Thread] Current Thread [Next in Thread>