Procmailrc perl and appending to file


I’m a bit stumped on this one. I’ve got a procmailrc file:



  • ^
    | $HOME/perlMailHandler

that pipes to a perl script:

Send filename to PHP script for parsing

$exit_status = system("/path/to/php -q /path/to/script/phpMailHandler.php testfile.txt");

Open the log

open (THEFILE, “>> incomingPerlLog.txt”);

Get the current date and time

$theTime = localtime;

Write the log entry

print THEFILE “$theTime: Incoming Mail recieved. \n”;

close file

close (THEFILE);

If I call it from the commandline (perl perlMailHandler) it works, no problem. But when the procmailrc pipes to it on an incoming mail, it won’t write to the file. I also have it calling a php script and passing a fake filename. The PHP file also writes to a log file. And this works on an incoming email. There is also a logfile for procmailrc and it shows perlMailHandler being executed without error. So I know the perl script is being called and completing.

Why wouldn’t the perl script append to a file on an incoming pipe from procmailrc but do it just fine when called from command line??


Are you specifying the paths to the log file? And what about basic error checking. Obviously one would want to check if the file exists and if the file was opened. Just because it works from command line does not mean it will work when called by another process - the environment is not going to be the same.

:cool: [color=#6600CC]Atropos[/color] |