[comp.mail.mh] Using Unseen to check for new mail

appel@ocf.Berkeley.EDU (Shannon D. Appel) (03/08/91)

I've been using mh for some time, but I just started using slocal
the other evening.  I set my unseen variable (Unseen-Sequence: unseen)
so that I could put this line in my .login: scan +inbox unseen.  Anyways,
this produces the following ugly output if you have no new mail:

scan: bad message list unseen

and I'd like my .login to be a bit more elegant than that.  So, my 
question is, is there any nice way to do something like this:

if (YOU_HAVE_UNSEEN_MAIL_IN_FOLDER_X) then ...

Thanks in advance for any input.

rgm@OCF.Berkeley.EDU (Rob Menke) (03/08/91)

It's not pretty but I use:

(show unseen > /dev/tty) >& /dev/null
--
					|  Robert Menke
"CLANG?!?  Did you say 'Clang?'"	|    rgm@OCF.berkeley.edu
					|    ...!ucbvax!OCF!rgm

jamesp@metolius.wr.tek.COM (James T Perkins) (03/08/91)

Howdy Shannon (Traveller Mailing List subscriber!),

Very simply, you could say:

	sh -c "scan +inbox unseen 2>/dev/null"

Which sends the error output to the bitbucket.  It depends on /bin/sh to
redirect stderr without redirecting stdout (one of things csh doesn't do
without major frustration).

You could make this more indirect using csh only, with:

	mhpath +inbox unseen >&/dev/null
	if ($status == 0) scan +inbox unseen

Or something like that.  The mhpath lists out the pathnames of the
messages in unseen, and sends them to the bitbucket.  It sets csh
variable status to 0 (success) if there is at least one unseen message,
and to 1 (error) if there are no unseen messages (the error message,
identical to scan's, has been redirected to the bitbucket).  The if
tests whether the mhpath suceeded or failed. if it suceeded (at least
one message), it runs scan on the unseen messages.

James (Traveller Mailing List Admin)

 ___    ___   ___
|   \  / _ \ / __|  James Perkins, jamesp@metolius.wr.tek.com, (503)629-1149
| |> || |_| |\__ \  Logic Analyzers Division, DAS 9200 Engineering
|___/ |_| |_||___/  Tektronix, MS 92-725, PO Box 4600, Beaverton, OR 97076

This package is sold by weight, not by volume.  Some settling of contents may
have occurred during shipping and handling.

ziegast@EGYPT.ENG.UMD.EDU (Eric Ziegast) (03/08/91)

Rob Menke writes:
>It's not pretty but I use:
>
>(show unseen > /dev/tty) >& /dev/null

Look at mh-profile(5) for more info on using the "unseen" sequence.
You need to add this entry to your .mh_profile:

	Unseen-Sequence: unseen

to make sure this works.
________________________________________________________________________
Eric W. Ziegast, University of Merryland, Engineering Computing Services
ziegast@eng.umd.edu - Eric@(301.405.3689)

khera@thneed.cs.duke.edu (Vick Khera) (03/08/91)

In article <APPEL.91Mar7114337@swindle.ocf.Berkeley.EDU> appel@ocf.Berkeley.EDU (Shannon D. Appel) writes:

   question is, is there any nice way to do something like this:

   if (YOU_HAVE_UNSEEN_MAIL_IN_FOLDER_X) then ...


i use the following shell script which i call usmail (for unseen mail)

---cut here---
#!/bin/csh -f
# V. Khera
# print out listing of unseen mail in mh folder +inbox
# $Id: usmail.csh,v 1.1 90/11/15 17:36:24 khera Exp $
set foo = `mark +inbox -list -sequence unseen`
if ("$foo[2]" != "(null)") then
  echo "Unseen mail (inbox):"
  scan unseen
else
  echo "No unseen mail in inbox."
endif
---cut here---

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vick Khera, Gradual Student/Systems Guy   Department of Computer Science
ARPA:   khera@cs.duke.edu                 Duke University
UUCP:   ...!mcnc!duke!khera               Durham, NC 27706     (919) 660-6528