[comp.mail.mh] changing a path for the inc command only

laurap@sword.bellcore.com (Laura R. Pate) (12/14/90)

I am setting up a mail group for several users and would like to offer
them a way to automatically refile mail from a particular source
when inc is invoked. I want this to be as transparent to them as possible. 
I've put together a shell script (my thanks to Jerry Peek) that calls
inc, scans 
the messages and refiles according to the 'to' field. I can alias this
script to inc and have it work as I'd like, but I have two problems/questions:

1- is there a better way to do this? Could I somehow change where mh
looks for inc? MhPath changes where it looks for all mh commands and I
don't want to get into having a separate set of mh commands (or even a
separate directory link) just for these users.

2- There are also xmh users and I'd like to change where xmh looks for inc too.
Just aliasing it doesn't work in this case.

Any ideas would be appreciated.
Thanks,

Laura Pate

allbery@NCoast.ORG (Brandon S. Allbery KB8JRR) (12/16/90)

As quoted from <1990Dec14.154913.22032@porthos.cc.bellcore.com> by laurap@sword.bellcore.com (Laura R. Pate):
+---------------
| I am setting up a mail group for several users and would like to offer
| them a way to automatically refile mail from a particular source
| when inc is invoked. I want this to be as transparent to them as possible. 
+---------------

This isn't provided in inc, on the theory that it's handled at a different
point in the delivery process.  Look into slocal, and maildelivery(5).

Arguably, you may want it in inc if you e.g. want the scan listing to show up
and want to read such messages after inc'ing them, but until sequences are
enhanced to allow multiple folders, this isn't very easy to implement within
MH.

(I would very much like to see some kind of multiple-folder sequences myself.)

++Brandon
-- 
Me: Brandon S. Allbery			    VHF/UHF: KB8JRR on 220, 2m, 440
Internet: allbery@NCoast.ORG		    Packet: KB8JRR @ WA8BXN
America OnLine: KB8JRR			    AMPR: KB8JRR.AmPR.ORG [44.70.4.88]
uunet!usenet.ins.cwru.edu!ncoast!allbery    Delphi: ALLBERY

ziegast@ENG.UMD.EDU (Eric Ziegast) (12/17/90)

"Laura R. Pate" writes:
>I am setting up a mail group for several users and would like to offer
>them a way to automatically refile mail from a particular source
>when inc is invoked. I want this to be as transparent to them as possible. 
>I've put together a shell script (my thanks to Jerry Peek) that calls
>inc, scans 
>the messages and refiles according to the 'to' field. I can alias this
>script to inc and have it work as I'd like, but I have two problems/questions:

Using shell scripts is the best way to go if you don't want to reinvent
the wheel (MH).  I envy Jerry in his mastering of sh & mh to create new
commands out of old.

>1- is there a better way to do this? Could I somehow change where mh
>looks for inc? MhPath changes where it looks for all mh commands and I
>don't want to get into having a separate set of mh commands (or even a
>separate directory link) just for these users.

Why not?  With a new directory, you can just add an entry to the PATH
variable rather than a zillion aliases for your new scripts.

For example, if you have a directory called /usr/local/bin/mh on your
system, you can create a directory called /usr/local/bin/mh/bin/new,
stick your new shell scripts in there, and have the people in the
mail group prepend the bin/new directory to their PATH variable in
their .cshrc file.  That way any time a command is searched for using
PATH, the new commands will be found before the standard ones.
Normal users not in the mail group won't have to add the new directory.

>2- There are also xmh users and I'd like to change where xmh looks for
>inc too.  Just aliasing it doesn't work in this case.

If I'm not mistaken, xmh should use execvp(2) or execlp(2) like any other
good Unix program.  In this case, the PATH variable is searched for the
command to use.  Be careful though; your shell scripts should take all of
the arguments of the origional commands so as to provide 100% compata-
bility for other programs (like xmh,msh,vmh,emh,etc) to use.

Hope this helps.
________________________________________________________________________
Eric W. Ziegast, University of Merryland, Engineering Computing Services
ziegast@eng.umd.edu - Eric@(301.405.3689)

jerry@ora.ora.COM (Jerry Peek) (12/18/90)

Laura Pate wrote:
> ... to automatically refile mail from a particular source
> when inc is invoked. I want this to be as transparent to them as possible. 
> I've put together a shell script (my thanks to Jerry Peek)...

You're welcome.  BTW, I've been getting a fair amount of mail asking
about the new Nutshell Handbook that I wrote on MH & xmh.  It's going
to the printer this week and should be out mid-January.  It has two
chapters about shell programming and programming with MH, as well as
a lot of other info about customizing MH and xmh.  But enough of that...

> 1- is there a better way to do this? Could I somehow change where mh
> looks for inc?

I like Eric Ziegast's idea of making a new directory and adding it
to the PATH.  Just be careful that the new PATH doesn't get propagated
to programs or users who need the default version of 'inc'.

>2- There are also xmh users and I'd like to change where xmh looks for inc too.
>Just aliasing it doesn't work in this case.

In the book, I suggest making a directory full of symbolic links that
point to the real MH commands, like this:
	forw -> /usr/local/mh/bin/forw
But, instead of making a link to the "real inc" in /usr/local/mh/bin/inc,
link to your front-end 'inc' shell script.  Or, just put the script in
the directory with the symlinks.  Then, set xmh's MhPath to point to your
new directory.

In fact, you could use this directory for MH users, too.  Put it in
their PATH ahead of the default MH directory.

--Jerry Peek, jerry@ora.com (on vacation until January, whew)