Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 17 May 1997 14:50:10 +1000
From:      Joel Sutton <sutton@aardvark.apana.org.au>
To:        Joseph Stein <joes@joes.users.spiritone.com>
Cc:        FreeBSD Questions List <freebsd-questions@freebsd.org>
Subject:   Re: Pager gateway? 
Message-ID:  <199705170450.OAA00355@solsbury-hill.home>
In-Reply-To: Your message of "Sat, 10 May 1997 19:52:51 MST." <199705110431.VAA02567@joes.users.spiritone.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
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 (<STDIN>) {
	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...










Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199705170450.OAA00355>