From owner-freebsd-questions Fri May 16 22:39:48 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id WAA09140 for questions-outgoing; Fri, 16 May 1997 22:39:48 -0700 (PDT) Received: from yarrina.connect.com.au (yarrina.connect.com.au [192.189.54.17]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id WAA09131 for ; Fri, 16 May 1997 22:39:42 -0700 (PDT) Received: from aardvark (aardvark.apana.org.au [203.12.237.49]) by yarrina.connect.com.au with ESMTP id PAA03250 (8.8.5/IDA-1.6); Sat, 17 May 1997 15:36:15 +1000 (EST) Received: from solsbury-hill.home (dialup-2.aardvark.apana.org.au [203.12.237.65]) by aardvark (8.8.4/8.6.9) with ESMTP id PAA30855; Sat, 17 May 1997 15:36:07 +1000 Received: from solsbury-hill.home (localhost.home [127.0.0.1]) by solsbury-hill.home (8.7.5/8.7.3) with ESMTP id OAA00355; Sat, 17 May 1997 14:50:10 +1000 (EST) Message-Id: <199705170450.OAA00355@solsbury-hill.home> X-Mailer: exmh version 2.0beta 12/23/96 From: Joel Sutton To: Joseph Stein cc: FreeBSD Questions List Subject: Re: Pager gateway? In-reply-to: Your message of "Sat, 10 May 1997 19:52:51 MST." <199705110431.VAA02567@joes.users.spiritone.com> Mime-Version: 1.0 Content-Type: text/plain Date: Sat, 17 May 1997 14:50:10 +1000 Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Joe, > I would like to write myself (in fact, I have) a script that will send > the Date, From, and Subject of messages in my incoming mail spool. > > I thought I could do it with chat, but apparently cannot (chat keeps reading > from the file and doing the send-expect thing). Here's a little perl script that might get you started: [snip] #!/usr/bin/perl while () { chop ; $date = $_ if /^[Dd]ate:/ ; $from = $_ if /^[Ff]rom:/ ; $subject = $_ if /^[Ss]ubject:/ ; } open (PAGER, "|/usr/bin/write jsutton") ; printf (PAGER "$date\n$from\n$subject\n") ; close (PAGER) ; [snip] You will need to add something like this into your .forward file: "|/usr/local/bin/perl /usr/home/jsutton/src/pager.pl ||exit 75 jsutton" What you decide to do with the date, from and subject variables after the open statement is left for you to decide. You could easily re-mail it to a pager gateway with /usr/bin/mail but be careful of using the variables in the open statement (security holes!!). If you really need to process your /var/mail/mailfile then I would suggest you use procmail to help you out. It has a great tool called formail which could pipe each individual message to the above script. Not bad for a quick slap-together at 23:30 eh? ;-) Hope this helps, Joel...