From owner-freebsd-questions Wed Dec 18 10:34:49 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8D67E37B401 for ; Wed, 18 Dec 2002 10:34:47 -0800 (PST) Received: from slate.dublin.wbtsystems.com (slate.dublin.wbtsystems.com [193.120.231.12]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5D21843ED8 for ; Wed, 18 Dec 2002 10:34:45 -0800 (PST) (envelope-from barry.byrne@wbtsystems.com) Received: from spiral (spiral.dublin.wbtsystems.com [193.120.231.190]) (authenticated bits=0) by slate.dublin.wbtsystems.com (8.12.6/8.12.6) with ESMTP id gBIIYg7n040148; Wed, 18 Dec 2002 18:34:42 GMT From: "Barry Byrne" To: "Mxsmanic" , "FreeBSD Questions" Subject: RE: Getting Perl scripts to work as mail filters Date: Wed, 18 Dec 2002 18:34:40 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 In-Reply-To: Importance: Normal X-WBT-Authenticated-User: bb X-Scanned-By: slate/MIMEDefang 2.28 (www . roaringpenguin . com / mimedefang) Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > -----Original Message----- > From: owner-freebsd-questions@FreeBSD.ORG > [mailto:owner-freebsd-questions@FreeBSD.ORG]On Behalf Of Mxsmanic > *** Well it looks like your script is being run - what should your script > do? *** > Heck, it's so simple I can list it here: > #!/usr/bin/perl > > while ($inputline = ) > { > $inputline =~ s/18 Dec 2002/29 Dec 2013/; > print STDOUT $inputline; > } > The s/// stuff is just to give me some proof that the script saw the > message. I'm not getting anything at all now, though. > I assumed that writing to STDOUT would somehow get the message delivered, > but maybe not. But if that's not the way to get it delivered, > what is? The How do you expect sendmail to know which user to deliver to? By altering the aliases file, you have said to sendmail: Don't deliver to localuser 'mymail', Instead deliver to the script 'perlfilter' If you don't need your script to modify the data that get's sent, then you could just add another recipient in the aliases file: mymail: "| perlfilter", myusername If you want to modify the message before sending it elsewhere, you could do something like: #!/usr/bin/perl $SENDMAIL="/usr/sbin/sendmail -bm"; $MYADDRESS="me\@mydomain.com"; open(SENDMAIL, "| $SENDMAIL $MYADDRESS") or die "Can't open $SENDMAIL"; while ($inputline = ) { $inputline =~ s/18 Dec 2002/29 Dec 2013/; print SENDMAIL $inputline; } close(SENDMAIL); > sendmail manual is not at all clear on this. I looked in sendmail.cf for > the name of some program to which perhaps I should pipe STDOUT in the > aliases file, but couldn't find anything. When the aliases file does not > specify piping of messages to some special program, who normally delivers > them? > > *** sendmail doesn't do anything with the STDOUT from your script. I'm nut > sure what you mean by 'delivers whatever comes out' - where would > it deliver > it? *** > > To my mailbox. I want the script to see incoming messages just > before they > get deposited in my mailbox on the server. From what I can understand of > how this works, some program actually receives the messages from sendmail > (?) and deposits them in my /usr/home/$USER mailbox, which appears to be > just a simple text file (I can't find any reference giving the format of > that, either). > It's running as root on my system. I thought it _had_ to run as root (?); > doesn't it have to access mailboxes that have only 600 access or > something? Older versions ran as root - current recommended setup is not to run as root. But that's another issue. - Barry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message