procmail
[Top] [All Lists]

[Solved] Re: variable=| not assigned to STDOUT

2001-12-12 04:46:12

I'll reply to David's answer since this is what helped me.

"David W. Tamkin" wrote:

| I have a simple test example that should return the standard out of
| a program into SCR but doesn't. I have no idea why. In the PERL script
| I even have it sending to both STDOUT and STDERR to no avail. Here is the
| .procmailrc snippet:
|
| SHELL=/bin/sh
| LOGABSTRACT=all
|
| :0 Wi
| SCR=| /u/bynum/spam/rbl-check3.pl -all
|
| :0:
| * SCR ?? .
| spamtest

| procmail: Executing "/u/bynum/spam/rbl-check3.pl,-all"
| procmail: Assigning "SCR="
| -osirusoft returns 127.0.0.2 for 198.5.241.40, mail is probably spam.
| procmail: Non-zero exitcode (25) from "/u/bynum/spam/rbl-check3.pl"
| procmail: No match on "."

Are you positive that the output goes to both?  I see the result of stderr
in your log but it's not so easy to tell what stdout is.  When you run it
from a shell prompt, do you see the output twice on the terminal?

Yes, positive it went to both. From the command prompt I got 2 copies.


I think the first thing we need to do is to see what really is in stdout.
Try this:

 :0 Wi
 SCR=| /u/bynum/spam/rbl-check3.pl -all

 LOG="The value if \$SCR is $SCR
"

and we'll know for sure.  Maybe the output is getting only to stderr and
nowhere else.

SCR was still undefined.

The next thing is like Martin's answer: perhaps the W, by its nature of
meaning "wait for the exit code of the program and put things back as they
were if it is non-zero" is preventing procmail from assigning SCR when the
exit code is not zero.  I don't like the man page's description of "wait for
the program to finish" because when the program is a filter or its stdout is
captured in a variable, of *course* procmail has to wait for the program to
finish, with or without `w' or `W' on the flag line.   What happens if you
drop the `W'?

This is what confused me, the "wait for the program to finish." I
thought that
this was always needed in a pipe. Can we change the man page? Removing
the 'W' did the trick, i.e. SCR was assigned the output of the program.
The
man page should include that 'w' or 'W' means check the exitcode, and if
the program
fails, resulting variables from it aren't assigned. I guess this is what
it tried
to say in "if the filter is unsuccessful, then the text will not have
been filtered."
I didn't think this was applicable because I didn't do any filtering.


| The program is supposed to return non-zero in
| case of a match, like above.

Do you really need to test on the output, then, or is testing on the exit
code enough?  If the exit code is non-zero for mail that belongs in the
spamtest folder and zero for mail that doesn't,

Yes, I need the output to stick in an X-Spam header which will be
filtered away
further down.

If /u/bynum is your home directory, I'd recommend invoking the perl script
as $HOME/spam/rbl-check3.pl in case the system is reorganized and your home
directory is relocated.  Even if you're the sysadmin and the reorganization
wouldn't come as a surprise to you, by referencing $HOME instead of the
absolute path you won't have to edit your .procmailrc if you move your home
directory.

I changed it from $HOME to /u/bynum to try and eliminate anything else
that
may cause a problem. I didn't want SHELLMETAs getting in the way. I'll
change
it back though.


Thanks for all the help!

Mark
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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