summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/cvs/contrib/mfpipe.in
blob: 1ecceb069018b25347f0a522ac491ddc098a1958 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#! @PERL@
# -*-Perl-*-
#
# From: clyne@niwot.scd.ucar.EDU (John Clyne)
# Date: Fri, 28 Feb 92 09:54:21 MST
# 
# BTW, i wrote a perl script that is similar to 'nfpipe' except that in
# addition to logging to a file it provides a command line option for mailing
# change notices to a group of users. Obviously you probably wouldn't want
# to mail every change. But there may be certain directories that are commonly
# accessed by a group of users who would benefit from an email notice. 
# Especially if they regularly beat on the same directory. Anyway if you 
# think anyone would be interested here it is. 
#
#	File:		mfpipe
#
#	Author:		John Clyne
#			National Center for Atmospheric Research
#			PO 3000, Boulder, Colorado
#
#	Date:		Wed Feb 26 18:34:53 MST 1992
#
#	Description:	Tee standard input to mail a list of users and to
#			a file. Used by CVS logging.
#
#	Usage:		mfpipe [-f file] [user@host...]
#
#	Environment:	CVSROOT	
#				Path to CVS root.
#
#	Files:
#
#
#	Options:	-f file	
#				Capture output to 'file'
#			

$header = "Log Message:\n";

$mailcmd = "| mail -s  'CVS update notice'";
$whoami = `whoami`;
chop $whoami;
$date = `date`;
chop $date;

$cvsroot = $ENV{'CVSROOT'};

while (@ARGV) {
        $arg = shift @ARGV;

	if ($arg eq '-f') {
                $file = shift @ARGV;
	}
	else {
		$users = "$users $arg";
	}
}

if ($users) {
	$mailcmd = "$mailcmd $users";
	open(MAIL, $mailcmd) || die "Execing $mail: $!\n";
}
 
if ($file) {
	$logfile = "$cvsroot/LOG/$file";
	open(FILE, ">> $logfile") || die "Opening $logfile: $!\n";
}

print FILE "$whoami $date--------BEGIN LOG ENTRY-------------\n" if ($logfile);

while (<>) {
	print FILE $log if ($log && $logfile);

	print FILE $_ if ($logfile);
	print MAIL $_ if ($users);

	$log = "log: " if ($_ eq $header);
}

close FILE;
die "Write failed" if $?;
close MAIL;
die "Mail failed" if $?;

exit 0;