m23
06-04-2005, 11:03 AM
I am working on writing an email filter in Perl, and I keep having problems: a script works just fine on the command line but does not work when used as a filter. For example, a very simple script (test.pl):
#!/usr/bin/perl
while($line = <>){print $line;}
Shouldn't this just print out the email, essentially doing nothing to it? As a processing filter, this doesn't work. From the command line it's fine:
perl spam.pl < email.txt
I get the contents of email.txt printed to the screen. But when set as a processing filter via Command 'N Control, I never get my email. It doesn't get bounced, either, and there's nothing in my /logs_email/filter.log file. The file is empty.
Also, I thought maybe it's just me, but the futurequest example script doesn't work either. You would think an example script would work ;) In the original example, the first line was #!/usr/local/bin/perl and I changed it to #!/usr/bin/perl but didn't make any difference.
#!/usr/bin/perl
# name of file where text for footer
# tag is stored
$filename = "tag.txt";
# read the original email message from
# STDIN one line at a time and
# print each line to STDOUT
while () { print; }
# open the file with the contents
# for the tag
open(TAGFILE, "<$filename") or die "Could not open tag.txt";
# read in the contents of the tag
# file a line at a time and
# print each line to STDOUT
while () { print; }
close(TAGFILE);
I have written scripts to do work, but sometimes they do sometimes they don't. I feel like I'm missing something really obvious.
#!/usr/bin/perl
while($line = <>){print $line;}
Shouldn't this just print out the email, essentially doing nothing to it? As a processing filter, this doesn't work. From the command line it's fine:
perl spam.pl < email.txt
I get the contents of email.txt printed to the screen. But when set as a processing filter via Command 'N Control, I never get my email. It doesn't get bounced, either, and there's nothing in my /logs_email/filter.log file. The file is empty.
Also, I thought maybe it's just me, but the futurequest example script doesn't work either. You would think an example script would work ;) In the original example, the first line was #!/usr/local/bin/perl and I changed it to #!/usr/bin/perl but didn't make any difference.
#!/usr/bin/perl
# name of file where text for footer
# tag is stored
$filename = "tag.txt";
# read the original email message from
# STDIN one line at a time and
# print each line to STDOUT
while () { print; }
# open the file with the contents
# for the tag
open(TAGFILE, "<$filename") or die "Could not open tag.txt";
# read in the contents of the tag
# file a line at a time and
# print each line to STDOUT
while () { print; }
close(TAGFILE);
I have written scripts to do work, but sometimes they do sometimes they don't. I feel like I'm missing something really obvious.