procmail
[Top] [All Lists]

Re: procmail: Piping to a PHP script.

2010-08-06 20:29:16
You need to comment out lines 2 and 4 of echo.php

On 8/6/10, Joel Lee <joel(_dot_)lee8(_at_)gmail(_dot_)com> wrote:
Hello.

I have my .procmailrc file set up to pipe mail to a simple php script I've
written. The only thing the script does at this point is echo back a "hello"
message. However, procmail does not execute the script properly.

Here's my script (/home/webs/site.com/scripts/echo.php):

 Code:

#!/usr/local/bin/php
<?php
echo "hi.";
?>

When I execute this script from the shell, it performs as expected. A
message is echoed to the terminal ("hi.") and the script quits.

Here is my .procmailrc:

 Code:

LOGFILE=/var/log/procmail.log
VERBOSE=YES
:0
| /home/webs/site.com/scripts/echo.php

And here is what is logged by procmail:


 Code:

procmail: [11765] Fri Aug  6 16:12:48 2010
procmail: Executing "/home/webs/site.com/scripts/echo.php"
procmail: [11765] Fri Aug  6 16:12:48 2010
procmail: Assigning "LASTFOLDER=/home/webs/site.com/scripts/echo.php"
procmail: Notified comsat: "root@:/home/webs/site.com/scripts/echo.php"
From fodii2160(_at_)quicknet(_dot_)nl  Fri Aug  6 16:12:48 2010
 Subject: Heard of the fellowship?
  Folder: /home/webs/site.com/scripts/echo.php                     728
/home/webs/site.com/scripts/echo.php: line 2: ?php: No such file or
directory
/home/webs/site.com/scripts/echo.php: line 4: syntax error near
unexpected token `newline'
/home/webs/site.com/scripts/echo.php: line 4: `?>'
procmail: [11769] Fri Aug  6 16:13:00 2010
procmail: Executing "/home/webs/site.com/scripts/echo.php"
/home/webs/site.com/scripts/echo.php: line 2: ?php: No such file or
directory
/home/webs/site.com/scripts/echo.php: line 4: syntax error near
unexpected token `newline'
/home/webs/site.com/scripts/echo.php: line 4: `?>'
procmail: [11769] Fri Aug  6 16:13:00 2010
procmail: Error while writing to "/home/webs/site.com/scripts/echo.php"
procmail: Assigning "LASTFOLDER=/home/webs/site.com/scripts/echo.php"
procmail: Locking "/var/mail/root.lock"
procmail: Assigning "LASTFOLDER=/var/mail/root"
procmail: Opening "/var/mail/root"
procmail: Acquiring kernel-lock
procmail: Unlocking "/var/mail/root.lock"
procmail: Notified comsat: "root(_at_)1356229:/var/mail/root"
From mudepeli7695(_at_)rr(_dot_)com  Fri Aug  6 16:13:00 2010
 Subject: Intense - the secret
  Folder: /var/mail/root

It appears that when procmail runs the script, the "#!/usr/local/bin/php"
isn't recognized, so it's being run as if it's a shell script instead of
using the php interpreter. This would explain errors such as "line 2: ?php:
No such file or directory". (If you just run a php script from the command
line without the path to the interpreter, that's exactly the kind of error
you'll get).

I've tried modifying my .procmailrc file like so:

:0
| /usr/local/bin/php /home/webs/site.com/scripts/echo.php

(I removed the path to the interpreter from the script itself when running
as above.) No joy. I'm at my wit's end here.

If the script were being executed properly, I would see the "hi." message
being echoed back in procmail.log instead of the execution errors.

Help?



-- 
John Wesley Simpson
SwaJime's Cove℠
www.swajime.com

____________________________________________________________
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