Return-Path: ckk@comet.scr.siemens.com 
Return-Path: <ckk@comet.scr.siemens.com>
Received: from Eng.Sun.COM by sage.Eng.Sun.COM (SMI-8.6/SMI-SVR4)
	id OAA16127; Tue, 4 Mar 1997 14:07:09 -0800
Received: from mercury.Sun.COM by Eng.Sun.COM (SMI-8.6/SMI-5.3)
	id OAA22796; Tue, 4 Mar 1997 14:07:08 -0800
Received: from mail.acm.org (mail.acm.org [199.222.69.4]) by mercury.Sun.COM (SMI-8.6/mail.byaddr) with SMTP id OAA03952 for <brent.welch@eng.sun.com>; Tue, 4 Mar 1997 14:05:42 -0800
Received: from scr.siemens.com (scr.siemens.com [129.73.1.15]) by mail.acm.org (8.8.4/8.7.5) with ESMTP id RAA20344 for <welch@acm.org>; Tue, 4 Mar 1997 17:05:19 -0500
Received: from comet.scr.siemens.com (comet.scr.siemens.com [129.73.9.14]) by scr.siemens.com (8.7.1/8.6.6) with ESMTP id RAA18408; Tue, 4 Mar 1997 17:04:49 -0500 (EST)
Received: from comet.scr.siemens.com (localhost [127.0.0.1]) by comet.scr.siemens.com (8.7.5/8.6.6) with ESMTP id RAA10696; Tue, 4 Mar 1997 17:05:26 -0500 (EST)
Message-Id: <199703042205.RAA10696@comet.scr.siemens.com>
X-Mailer: exmh version 2.0gamma 1/27/96
From: ckk@pobox.com
Reply-To: ckk@pobox.com
To: welch@acm.org
Cc: ckk@pobox.com
Subject: exmh contribution: Hook_Background and "procbox"
Mime-Version: 1.0
Date: Tue, 04 Mar 1997 17:05:26 -0500
Sender: ckk@scr.siemens.com
Content-Type: multipart/mixed ;
	boundary="==_Exmh_-4987268400"
Content-Length: 3135

This is a multipart MIME message.

--==_Exmh_-4987268400
Content-Type: text/plain; charset=us-ascii

version 2.0gamma 1/27/96
SunOS comet.scr.siemens.com 5.5 Generic sun4m sparc sun4m
Tk 4.2 Tcl 7.6

Hello Brent,

I think I just got my custom "Hook_Background" function working, which 
invokes my "procbox" shellscript, to run procmail/rcvstore on my mail spool, 
here's a copy if you're interested in including it in some contrib archive 
etc. as an alternative to using "slocal".

Here's my situation: my machine is unstable and crashes for some weird reason 
so I have my mail delivered to another host and I mount that host's /var/mail 
here. So I can't have anything automatically done via my .forward file upon 
delivery.

But, I still want to run procmail, and filter messages with 'rcvstore' in my 
.procmailrc. I already learned .procmailrc filtering syntax, and don't want 
to learn "slocal" syntax :-)

So, I define a Hook_Background at the end of my "~/.tk/exmh/user.tcl" which 
calls my "procbox" script which calls procmail on my mail spool.....

Here is "my_background.tcl" and "procbox" which it invokes.

I was confused at first, from your "Customizing exmh" Web page, "Programming 
exmh" section; I thought I could just put my Hook_Background into a new 
"~/.tk/exmh/my_background.tcl" file, do the auto_mkindex of it, and restart 
exmh and all would work. But no, I had to copy your user.tcl to my ~/.tk/exmh 
and then append this my_background.tcl to the end of it, and re-index, and 
THEN it worked.

I think I stole "procbox" from an archive of the procmail users' mailing 
list, but I forget who wrote it.... note that it uses "procmail", "formail", 
and "lockfile" which all come with Procmail.

--------------------
Chris Koenigsberg: ckk@scr.siemens.com (ckk@pobox.com)
Telephone +1-609-734-3389
Fax +1-609-734-6565
Computing and Network Administration, Siemens Corporate Research  
755 College Rd. East, Princeton NJ 08540 USA
& part-time graduate student, Rutgers University Computer Science Dept
<http://www.pobox.com/~ckk>




--==_Exmh_-4987268400
Content-Type: text/plain ; name="procbox"; charset=us-ascii
Content-Description: procbox
Content-Disposition: attachment; filename="procbox"

#!/bin/sh
          ORGMAIL=/var/mail/$LOGNAME

          if cd $HOME &&
           test -s $ORGMAIL &&
           lockfile -r0 -l1024 .newmail.lock 2>/dev/null
          then
            trap "rm -f .newmail.lock" 1 2 3 13 15
            umask 077
            lockfile -l1024 -ml
            cat $ORGMAIL >>.newmail &&
             cat /dev/null >$ORGMAIL
            lockfile -mu
            formail -s procmail <.newmail &&
             rm -f .newmail
            rm -f .newmail.lock
          fi
          exit 0


--==_Exmh_-4987268400
Content-Type: text/plain ; name="my_background.tcl"; charset=us-ascii
Content-Description: my_background.tcl
Content-Disposition: attachment; filename="my_background.tcl"

proc Hook_Background {} {
    global exmh

    if [catch {exec procbox} procout] {
	Exmh_Debug Hook_Background "procbox:" $procout
	set procout {}
    }

    Flist_Refresh
}
--==_Exmh_-4987268400--



