[comp.mail.mh] non-interactive MH

ken@cs.rochester.edu (Ken Yap) (02/22/88)

One of the things that irks me most about MH is the apparent inability
to use programs non-interactively. For instance I would sometimes like
to have an at job automatically dist notes.  You would think you could
feed stdin to MH programs, but no, prompter needs one EOF to exit and
then of course by definition there is nothing input left to send the
's' <return> to whatnow.

May I propose an option to prompter that would accept a dot (.) on a
line all by itself as EOF? This option would also supress the prompts
for the unfilled fields. Then I could do this from a script, assuming I
have the usual Resent-To and Resent-CC fields:

	% dist <<EOF
	jack, joe
	myself
	.
	s
	EOF

Is there a better way to do what I want? Don't tell me about the rcvxxx
programs, I know about those (they don't read MH_PROFILE for one thing
and I can't use my alias file) and I think those would have been
unnecessary if the standard MH programs had been designed to take stdin
as well.

	Ken

jsweet@ICS.UCI.EDU (Jerry Sweet) (02/22/88)

Does -nowhatnowproc do what you want?

-jns

jsweet@ICS.UCI.EDU (Jerry Sweet) (02/22/88)

> ... I have a couple of empty draft files.

> Did I miss something? What should I try next?

Hmmm.  Well, let me consult the Ancient Book of MH Lore...ah, yes.
You're right.  There is no extremely simple answer to do precisely
what you want, but it can be done with a little experimenting.  [Now I
remember the debates with the Elder MH Gods over whether dist should
have a non-interactive behavior---take its destination addresses from
the command line.  I lost.  You lost.]

For now, I suggest that you write your own simple whatnowproc (a shell
script might even do it) to take the message being distributed and a
list of addresses from standard input to generate a draft of the
appropriate form, then send it off.  Refer to MH-Profile(5) and the
discussion of environment variables $editalt and $mhdraft, which are
set by dist.

This is off the top of my head; an MH Guru may suggest something
simpler.

Hope this helps.

-jns

ted%braggvax.arpa@ICS.UCI.EDU (02/22/88)

Will mhmail do what you want?

Othewise, here's a script I use to redistribute rec.arts.comics articles 
from usenet to our local bboard after I've read them.  Clunky, but it 
seems to work.

You can put whatever you want in your distcomps file (even modify it with
each run).  Mine just has:

Resent-To: comics

#! /bin/sh
cd /usr2/a/ted/comics
folder +/usr2/a/ted/comics -push
for i in [0-9]*
do
rm -f /usr2/a/ted/Mail/draft
dist $i -noedit -form /usr2/a/ted/comics/.distcomps <<!
s
!
done
folder -pop


				Ted Nolan
				ted@braggvax.arpa

jamesp@dadla.la.tek.COM ("James T. Perkins") (02/23/88)

I have a mailing list that automatically redistributes messages.  I suggest
looking at the (undocumented) way that dist send's messages: send -dist.  I have
a shell script that adds a "Resent-To:" header to the original message, then
uses send -dist filename.

FYI, my send -help tells me the following about its version:

version: MH #5.13[UCI/UCB] (zephyr) of Mon Jul 27 07:16:24 PDT 1987

 _	___
| |    / _ \   James T. Perkins, jamesp@dadla.la.tek.com, (503)629-1149
| |__ | |_| |  Tektronix Logic Analyzers, DAS System Software, Disk Services
|____||_| |_|  MS 92-725, PO Box 4600, Beaverton OR 97075

Killed processes never die... They just go to the big Bit Bicket in the sky.

mayer@hplabsz.HPL.HP.COM (Niels Mayer) (02/23/88)

You can easily make comp, repl, dist, forw "noninteractive" by specifying
-whatnowproc mh/send to those programs. Assuming that those
programs somehow get a sendable draft file, specifying -whatnowproc as
above will just send it directly.

Here's an excerpt from a digest service script run nightly via at(1), just
so you can get the idea of how to use forw -digest:

	....
pick +lotsbb -after "$bb-timestamp"
forw +lotsbb select -digest LOTS-BBOARD -whatnowproc /usr/new/mh/send -form ~/bb-digester/bbdigestcomps -filter /usr/new/lib/mh/mhl.digest
	....

The draft format file ~/bb-digester/bbdigestcomps is the same as
lib/mh/digestcomps except that I hardwired the names of the people on the
distribution list and removed the hardwired "From:" entry for various
obscure reasons... You can also use the default draft format file in
lib/mh/digestcomps in conjunction with distribution lists in your mh-alias
file. 

-------------------------------------------------------------------------------
	    Niels Mayer -- hplabs!mayer -- mayer@hplabs.hp.com
		       Hewlett-Packard Laboratories
			      Palo Alto, CA.
				   *