zsh-users
 help / color / mirror / code / Atom feed
* MAIL variable help!
@ 1996-01-12 22:12 Pete Williams
  1996-01-13  3:51 ` Justin Sheehy
  0 siblings, 1 reply; 3+ messages in thread
From: Pete Williams @ 1996-01-12 22:12 UTC (permalink / raw)
  To: zsh-users


Hi,

I'm trying to set up my mail variables within zsh 2.5.03 so that whenever
mail arrives within one of my MH folders (it's been pre-filtered by mailagent),
I'll be notified for each folder with new mail.

As I have it setup now, it prints out a one-line notification for each mail
that's arrived, so that if I should get say 3 mails in ~/Mail/zsh, I get

New mail in zsh.
New mail in zsh.
New mail in zsh.

rather than just one notification.

Also, the manpage says that if an element in MAILPATH is a directory, that
directory is recursively scanned for every file.  I don't want this behavior;
it makes no sense with MH-style folders.  Also, it takes forever for zsh
to scan all my folders for new mail.

I can always write a separate program and invoke it "periodic"ally, but is
this really necessary?  Surely other zsh users use MH as well...

Also, while I'm at it, I have a similar problem with MAIL_WARNING, in that
if I "scan" an MH folder, I'll get a series of terminal messages like:

The mail in /u/pete/Mail/tqadm/1 has been read.
The mail in /u/pete/Mail/tqadm/8 has been read.
...
... many more lines here
...
The mail in /u/pete/Mail/tqadm/4 has been read.
The mail in /u/pete/Mail/tqadm/5 has been read.
The mail in /u/pete/Mail/tqadm/6 has been read.
The mail in /u/pete/Mail/tqadm/7 has been read.

Am I going about this the wrong way?

Thanks in advance,

Pete Williams <petew@lexis-nexis.com>

  "Hey, I had to let awk be better at *something*...  :-)"
    -- Larry Wall in <1991Nov7.200504.25280@netlabs.com>1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: MAIL variable help!
  1996-01-12 22:12 MAIL variable help! Pete Williams
@ 1996-01-13  3:51 ` Justin Sheehy
  1996-01-26 19:41   ` Program for Mail-checking MH folders Pete Williams
  0 siblings, 1 reply; 3+ messages in thread
From: Justin Sheehy @ 1996-01-13  3:51 UTC (permalink / raw)
  To: Pete Williams; +Cc: zsh-users

>I'm trying to set up my mail variables within zsh 2.5.03 so that whenever
>mail arrives within one of my MH folders (it's been pre-filtered by mailagent)

Good luck!

As an mh user and a zsh user, I have had this same problem.
You cannot get zsh to work with mh without extreme kludginess. What I
do is have my mail initially filtered into standard mailboxes, so that
zsh and xbuffy will work. Than I use a short script when I want to inc
the files into the appropriate folders. A bit hackish, but it works.

This has really annoyed the hell out of me, but I guess it would be a
bit unfair to insist on zsh conforming to mh's non-standard
mechanisms. (but it would be a nice option)


-Justin


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Program for Mail-checking MH folders
  1996-01-13  3:51 ` Justin Sheehy
@ 1996-01-26 19:41   ` Pete Williams
  0 siblings, 0 replies; 3+ messages in thread
From: Pete Williams @ 1996-01-26 19:41 UTC (permalink / raw)
  To: Justin Sheehy; +Cc: zsh-users

Justin Sheehy <dworkin@k2.ccs.neu.edu> writes:
>>I'm trying to set up my mail variables within zsh 2.5.03 so that whenever
>>mail arrives within one of my MH folders (it's been pre-filtered by mailagent
>
>As an mh user and a zsh user, I have had this same problem.
>You cannot get zsh to work with mh without extreme kludginess. What I

I had been trying to get the zsh "mail" variable to work with MH folders. 
As all my mail is prefiltered, my spoolfile rarely has any mail.  As zsh
has (apparently) no way of checking MH folders for new mail, I whipped up a
perl script to do the job.

What it does is build a "database" of you current MH folders (as a DBM
file), and then every time it's called, it looks at the "Unseen-Sequence"
line of each folder to see if there's anything new and prints out an
appropriate message to the terminal.

Additional notes head the program.
 
It's a quick hack, but it works for my purposes.  Hope someone else will
find it useful.

Pete Williams <petew@lexis-nexis.com>

--------------- SITUATION: Users Want Phone List Application ---------------
ADMINISTRATIVE FASCIST: Oracle.  Users give up and go back to post-it notes.
  -- Stephan Zielinski "KNOW YOUR UNIX SYSTEM ADMINISTRATOR - A Field Guide"

#! /usr/local/bin/perl
##############################################################################
# CHECKMH
#
# To find MH folders with new mail and print out those that do.
#
#  Install:
# 1. Change the $mailspool and $mailbox variables to point to your system
#    mail spooling directory and the name of your home mailbox directory,
#    respectively.
# 2. Change $dbmbase, $dbmfile, and $dbmpag if you wish your dbm file to be
#    something besides $maildir/.curfolders.
# 3. Look at your .mh_profile and check the value of "Unseen-Sequence".  Set
#    the variable $unseen_seq to this value.  If it's not there, add the line
#    "Unseen-Sequence: unseen" to .mh_profile.
# 4. If running under zsh, and you want to emulate the behavior of the 
#    "mail" variable,
#    -- add this line to ~/.zshenv: "export PERIOD=600"
#    -- add this line to ~/.zshrc:  "periodic () { ~/bin/checkmh }"
# 5. You should run this script with the "-i" option periodically so that
#    your current (existing) folders are kept updated.  Add a crontab entry
#    like the following:
#    23 19 * * 0-5 /u/pete/bin/checkmh -i
#
###############################################################################

$| = 1;

$mailspool = '/var/spool/mail';
$mailbox   = 'Mail';
$dbmbase   = '.curfolders';
$unseen_seq= 'unseen';

($name,$homedir) = (getpwuid($<))[0,7];

$spool   = "${mailspool}/$name";
$maildir = "${homedir}/$mailbox";
$dbmfile = "${maildir}/$dbmbase";
$dbmpag  = "${maildir}/${dbmbase}.pag";

$0 =~ s:^.*/::;

if ($_ = $ARGV[0]) {
	if (/^-i/) { 
		&update_mhfolders;
	} else {
		die <<"UrGgGh!";
usage: $0 [-i]
       $0   : check MH folders
       $0 -i: update folder list in folder database
UrGgGh!
	}
} else {
	&check_mail;
}

##############################################################################
# CHECK_MAIL
#
# Check system mailbox first, then all the MH folders
# Report results to STDOUT
##############################################################################

sub check_mail {
	&update_mhfolders unless -e $dbmpag;

	dbmopen(FOLDERDBM,$dbmfile,0666) || die "Can't open $dbmfile: $!";

	foreach $folder (sort keys %FOLDERDBM) {
		($basename = $folder) =~ s:^${maildir}/::;
		substr($basename,0,0) = '+';
		$seqfile = join('/',$folder,'.mh_sequences');
		open(SEQ,$seqfile); # No warning, but probably not a problem!
		while (<SEQ>) {
			next unless /^$unseen_seq:/;
			print "New mail in $basename.\n";
		}
		close SEQ;
	}

	dbmclose FOLDERDBM;
}

##############################################################################
# UPDATE_MHFOLDERS
#
# Initialize (-i)/update the mhfolders database.
# Updates a dbm file on the current folders in the MAIL directory.
# Normally run once at setup time and then added to the user's crontab file.
##############################################################################

sub update_mhfolders {
	local(%tmparray);
	require "find.pl";

	dbmopen(FOLDERDBM,$dbmfile,0666) || die "Can't open $dbmfile: $!";

	foreach $key (keys %FOLDERDBM) { delete $FOLDERDBM{$key}; }

	&find($maildir);

	warn "MH folders added to $dbmfile:\n";

	foreach $key (keys %tmparray) {
		unless ($key eq $maildir) {
			# If run by cron, this line should send you info about
			# new folders added to the dbm file.
			warn "    $key\n";
			$FOLDERDBM{$key}++;
		}
	}

	dbmclose FOLDERDBM;
	exit;
}

##############################################################################
# WANTED
# Traverse desired filesystems
##############################################################################

sub wanted {
	if ((($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) && -d _) {
		$name =~ s:^//:/:;
		$tmparray{$name}++;
	}
}


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1996-01-26 20:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-01-12 22:12 MAIL variable help! Pete Williams
1996-01-13  3:51 ` Justin Sheehy
1996-01-26 19:41   ` Program for Mail-checking MH folders Pete Williams

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).