procmail
[Top] [All Lists]

Re: Perl scripts not recognized as such?

2008-12-04 13:07:15

Thank you for your reply.

The script is really pretty simple, I've included it below.  (This is
to get started; when I have it working I'll be adding "exit 0 if ..."
statements.)

------------------------------- begin  -------------------------------

#!/usr/local/perl/bin/perl

my $rwFrom = '(Jeremiah Builds|builds|Polly Prerel|prerel)';

while (<STDIN>) {
  if (/^From: (.*)/) {
    exit 0 if $1 =~ /$rwFrom/;
  } elsif (/^Subject: (.*)/) {
    exit 0 if $1 =~ /\[Qt-interest\]/;
  }
}

exit 1;

-------------------------------- end  --------------------------------

Also, the problem doesn't seem to depend on the contents of the mail.
I'm using the recipe:

:0c
backup

to create backups.  If I take the backup of one of the messages which
failed and pipe it into the script, it doesn't fail:

procmail: Assigning "LASTFOLDER=backup/msg.97ZI"
procmail: Opening "backup/msg.97ZI"
procmail: Acquiring kernel-lock
procmail: Executing "/home/staff/billo/Mail/billo2.pl"
/home/staff/billo/Mail/billo2.pl: my: not found
...
procmail: Non-zero exitcode (2) from "/home/staff/billo/Mail/billo2.pl"
procmail: No match on "/home/staff/billo/Mail/billo2.pl"

animas: cat msg.97ZI | ~/Mail/billo2.pl
animas: 

Bill

Hmmmm. What does the script DO? That sort of 'works some of the time'
behaviour suggests that it is conditional on message content. You wouldn't
happen to be using 'eval' statements in your script, would you? These
could barf on stray unexpected characters in headers.... 

- Charles

On Thu, 4 Dec 2008, Bill Oakley wrote:
I'm using procmail to spool my "interesting" mail to my system mailbox
and my "uninteresting" mail to a secondary mailbox.  Specifically, I'm
using a Perl script and testing it's exit status.  My recipes are:

:0Wi:
* ? $HOME/Mail/billo2.pl
$HOME/Mail/billo2

:0:
$DEFAULT

My Perl script begins with:

#!/usr/local/perl/bin/perl

The problem I'm seeing is that sometimes the Perl script doesn't seem
to be recognized as a Perl script; my procmail log file contains:

procmail: Executing "/home/staff/billo/Mail/billo2.pl"
/home/staff/billo/Mail/billo2.pl: my: not found
/home/staff/billo/Mail/billo2.pl: my: not found
/home/staff/billo/Mail/billo2.pl: my: not found
/home/staff/billo/Mail/billo2.pl: syntax error at line 10: `)' unexpected
procmail: Non-zero exitcode (2) from "/home/staff/billo/Mail/billo2.pl"
procmail: No match on "/home/staff/billo/Mail/billo2.pl"

It's as though the Perl script is being interpreted as a shell script.
(And if I remove the "#!" line and run the script interactively I see
the same errors.)  But again, this only happens some of the time - the
rest of the time the script runs and the messages are spooled
correctly.

Any ideas about what the problem may be?

Thank you for your help.

Bill
____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail


____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail
____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail