[comp.sys.hp] biff

mck@hpcuhc.cup.hp.com (Doug McKenzie) (02/04/91)

>There is a UNIX BSD utility program called 'biff' which notifies the
>user about any incoming mail. Is there any similar program on HP-UX?
>If not, has anyone tried to write code with similar functionality.

Below is a slightly ancient, unsupported version, with man page.

Doug McKenzie
HP-UX Support


# This is a shell archive.  Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by Doug McKenzie <mck@hpcugsya> on Mon Feb  4 06:59:53 1991
#
# This archive contains:
#	biff.1	biff.c	
#

LANG=""; export LANG
PATH=/bin:/usr/bin:$PATH; export PATH

echo x - biff.1
cat >biff.1 <<'@EOF'
'''\"   UNISRC_ID	@(#)37.1   87/02/20
.TH BIFF 1 "18 July 1983"
.UC 4
.SH NAME
biff \- be notified if mail arrives and who it is from
.SH SYNOPSIS
.B biff
[
.B yn
]
.SH DESCRIPTION
.I Biff
informs the system whether you want to be notified when mail arrives
during the current terminal session.
The command
.IP
.B "biff y"
.LP
enables notification; the command
.IP
.B "biff n"
.LP
disables it.
When mail notification is enabled, the header and first few lines of
the message will be printed on your screen whenever mail arrives.
A ``biff y'' command is often included in the file
.I \&.login
or
.I \&.profile
to be executed at each login.
.PP
.I Biff
operates asynchronously.
For synchronous notification use the MAIL variable of
.IR sh (1)
or the
.I mail
variable of
.IR csh (1).
.SH SEE ALSO
csh(1),
sh(1),
mail(1),
comsat(8C)
@EOF

chmod 444 biff.1

echo x - biff.c
cat >biff.c <<'@EOF'
#ifdef hpux
#ifndef lint
static char *UNISRC_ID = "@(#)37.1   87/02/20";
#endif
/* HPUX_ID: @(#)biff.c	37.1     86/06/16 */

#else

#ifndef lint
static char *sccsid ="@(#)biff.c	4.2 (Berkeley) 7/2/83";
#endif
#endif not hpux
/*
 * biff
 */

#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>

char	*ttyname();

main(argc, argv)
	int argc;
	char **argv;
{
	char *cp = ttyname(2);
	struct stat stb;

	argc--, argv++;
	if (cp == 0)
		fprintf(stderr, "Where are you?\n"), exit(1);
	if (stat(cp, &stb) < 0)
		perror(cp), exit(1);
	if (argc == 0) {
		printf("is %s\n", stb.st_mode&0100 ? "y" : "n");
		exit((stb.st_mode&0100) ? 0 : 1);
	}
	switch (argv[0][0]) {

	case 'y':
		if (chmod(cp, stb.st_mode|0100) < 0)
			perror(cp);
		break;

	case 'n':
		if (chmod(cp, stb.st_mode&~0100) < 0)
			perror(cp);
		break;

	default:
		fprintf(stderr, "usage: biff [y] [n]\n");
	}
	exit((stb.st_mode&0100) ? 0 : 1);
}
@EOF

chmod 444 biff.c

exit 0

ken@hpclkms.cup.hp.com (Ken Sumrall) (02/05/91)

>There is a UNIX BSD utility program called 'biff' which notifies the
>user about any incoming mail. Is there any similar program on HP-UX?
>If not, has anyone tried to write code with similar functionality.
>
Biff(1) is easy to port to HP-UX.  All it does is set the owner execute bit
on the controlling tty of the user.  The trick is to get comsat(1m) working.
Comsat is a daemon that is run out of /etc/inetd.conf, and notifies the user
of new mail.  On BSD systems, the local delivery agent talks to comsat
over a socket, to tell it new mail has arrived, and then comsat tells the
user.

My solution to the problem, (since I couldn't hack the source of /bin/rmail),
was to make a mail wrapper program that replaced /bin/rmail. This program
forked a copy of /bin/rmail.orig to deliver the mail, and then talked to
comsat to have it report new mail to the user.  I got the wrapper program
off usenet a while ago, and hacked it for HP-UX.  The comsat program
is basically the comsat program from BSD, also slightly hacked.

If you want a copy of the source, send me email.

>Thanks in advance,
>
Your welcome.

>Masoud Majidi (majidi@paul.rutgers.edu)
>
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*                                   Ken Sumrall                               *
* Internet: ken%hpda@hplabs.hp.com        |        UUCP:  ...!hplabs!hpda!ken *
*    "I'd stomp desert dope heads for some gas in my moped!" - Bill the Cat   *
*              "What a stupid world" -Calvin (speaking to Hobbes)             *
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

lrb@alex.ctrg.rri.uwo.ca (Lance R. Bailey) (02/05/91)

>There is a UNIX BSD utility program called 'biff' which notifies the
>user about any incoming mail. Is there any similar program on HP-UX?

I wrote one a couple of years ago which handles either a single file or a 
directory tree. Also comes with some software to autosort your incoming
mail.

so, bob myers will send me mail, it gets sorted into folder "myers" and i get
a message stating "new mail in myers". if i have a folder called tubes and the
word tubes is in the subject line then the mail is stuck into that folder.

the whole thing is available via anon ftp from rrivax.rri.uwo.ca. that number
again is 129.100.7.2 daemons are waiting.......


-- 
Lance R. Bailey  Systems Manager        box: Robarts Research Institute
          email: lrb@rri.uwo.ca              Clinical Trials Resources Group
            fax: 519.663.3789                P.O. Box 5015, 100 Perth Dr.
            vox: 519.663.3787 ext. 4108      London, Canada N6A 5K8

Kimmo.Suominen@lut.fi (Kimmo Suominen) (02/06/91)

>>>>> On 3 Feb 91 16:10:58 GMT, majidi@yoko.rutgers.edu (Masoud Majidi) said:

Masoud> There is a UNIX BSD utility program called 'biff' which notifies the
Masoud> user about any incoming mail. Is there any similar program on HP-UX?
Masoud> If not, has anyone tried to write code with similar functionality.

Try fetching one from lut.fi using anonymous ftp.  The file you are
looking for is

	/unix/misc/biff.tar.Z

It implements both comsat (the biff server) and biff.  You also need
to change your sendmail's local delivery agent.  This is to notify
comsat, which in turn will notify the user.

This implementation also includes a networked feature, where you can
be notified about incoming on multiple hosts (of course they all need
to run this new comsat).  Should work on Suns also, I have never
tried.  And I don't use this networked feature, either.
--
Kim                      /  Internet: Kimmo.Suominen@lut.fi
"That's what I think."  /   Bitnet:   KIM@FINFILES

majidi@ringo.rutgers.edu (Masoud Majidi) (02/07/91)

About a week ago asking about a program with similar functionality to
'biff'. I would like to thank everyone who responded. I got even more
than I asked for! Now I know a lot more about all mail facilities of
hp.

Thanks again,

Masoud Majidi,