Promailrc and perl


#1

I’ve got the procmailrc file calling the appropiate perl script. That works fine and it writes to a log file. But I can’t seem to capture the STDIN in perl. Everytime I try $message = , then try to print FILE $message, the script won’t log anything. Any idea?

#!/usr/bin/perl
$message = ;
$theTime = localtime;
open THEFILE, ‘>> incomingPerlLog.txt’;
print THEFILE “$theTime: Incoming Mail recieved.”;
print THEFILE $message;
close THEFILE;


#2

is for interactive input. Command line arguments are stored in the @ARGV array. Try replacing with $ARGV[0].


If you want useful replies, ask smart questions.


#3

You’re assigning to a scalar When you do so, STDIN is read only up to the first linebreak. Either you need to assign to list, or use a loop.

[code]# iterate over lines in the message
while ($line = ) {

append next line to message

$message .= $line;
}[/code]

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


#4

Yeah, or that. That’s what I get for trying to answer Perl questions when I don’t actually speak it.


If you want useful replies, ask smart questions.


#5

Thanks for the suggestions but unfortunately neither one is working. Here is what I currently have:

#!/usr/bin/perl

Tried this but didn’t work like this or with

#$message = $ARGV[0];

iterate over lines in the message

while ($line = $ARGV[0]) {

append next line to message

$message .= $line;
}

$theTime = localtime;
open THEFILE, ‘>> incomingPerlLog.txt’;
print THEFILE "$theTime: Incoming Mail recieved: ";
print THEFILE $message;
close THEFILE;