1*43c1707eStholo#! @PERL@ 2*43c1707eStholo# -*-Perl-*- 3*43c1707eStholo# 4*43c1707eStholo# From: clyne@niwot.scd.ucar.EDU (John Clyne) 5*43c1707eStholo# Date: Fri, 28 Feb 92 09:54:21 MST 6*43c1707eStholo# 7*43c1707eStholo# BTW, i wrote a perl script that is similar to 'nfpipe' except that in 8*43c1707eStholo# addition to logging to a file it provides a command line option for mailing 9*43c1707eStholo# change notices to a group of users. Obviously you probably wouldn't want 10*43c1707eStholo# to mail every change. But there may be certain directories that are commonly 11*43c1707eStholo# accessed by a group of users who would benefit from an email notice. 12*43c1707eStholo# Especially if they regularly beat on the same directory. Anyway if you 13*43c1707eStholo# think anyone would be interested here it is. 14*43c1707eStholo# 15*43c1707eStholo# File: mfpipe 16*43c1707eStholo# 17*43c1707eStholo# Author: John Clyne 18*43c1707eStholo# National Center for Atmospheric Research 19*43c1707eStholo# PO 3000, Boulder, Colorado 20*43c1707eStholo# 21*43c1707eStholo# Date: Wed Feb 26 18:34:53 MST 1992 22*43c1707eStholo# 23*43c1707eStholo# Description: Tee standard input to mail a list of users and to 24*43c1707eStholo# a file. Used by CVS logging. 25*43c1707eStholo# 26*43c1707eStholo# Usage: mfpipe [-f file] [user@host...] 27*43c1707eStholo# 28*43c1707eStholo# Environment: CVSROOT 29*43c1707eStholo# Path to CVS root. 30*43c1707eStholo# 31*43c1707eStholo# Files: 32*43c1707eStholo# 33*43c1707eStholo# 34*43c1707eStholo# Options: -f file 35*43c1707eStholo# Capture output to 'file' 36*43c1707eStholo# 37*43c1707eStholo 38*43c1707eStholo$header = "Log Message:\n"; 39*43c1707eStholo 40*43c1707eStholo$mailcmd = "| mail -s 'CVS update notice'"; 41*43c1707eStholo$whoami = `whoami`; 42*43c1707eStholochop $whoami; 43*43c1707eStholo$date = `date`; 44*43c1707eStholochop $date; 45*43c1707eStholo 46*43c1707eStholo$cvsroot = $ENV{'CVSROOT'}; 47*43c1707eStholo 48*43c1707eStholowhile (@ARGV) { 49*43c1707eStholo $arg = shift @ARGV; 50*43c1707eStholo 51*43c1707eStholo if ($arg eq '-f') { 52*43c1707eStholo $file = shift @ARGV; 53*43c1707eStholo } 54*43c1707eStholo else { 55*43c1707eStholo $users = "$users $arg"; 56*43c1707eStholo } 57*43c1707eStholo} 58*43c1707eStholo 59*43c1707eStholoif ($users) { 60*43c1707eStholo $mailcmd = "$mailcmd $users"; 61*43c1707eStholo open(MAIL, $mailcmd) || die "Execing $mail: $!\n"; 62*43c1707eStholo} 63*43c1707eStholo 64*43c1707eStholoif ($file) { 65*43c1707eStholo $logfile = "$cvsroot/LOG/$file"; 66*43c1707eStholo open(FILE, ">> $logfile") || die "Opening $logfile: $!\n"; 67*43c1707eStholo} 68*43c1707eStholo 69*43c1707eStholoprint FILE "$whoami $date--------BEGIN LOG ENTRY-------------\n" if ($logfile); 70*43c1707eStholo 71*43c1707eStholowhile (<>) { 72*43c1707eStholo print FILE $log if ($log && $logfile); 73*43c1707eStholo 74*43c1707eStholo print FILE $_ if ($logfile); 75*43c1707eStholo print MAIL $_ if ($users); 76*43c1707eStholo 77*43c1707eStholo $log = "log: " if ($_ eq $header); 78*43c1707eStholo} 79*43c1707eStholo 80*43c1707eStholoclose FILE; 81*43c1707eStholodie "Write failed" if $?; 82*43c1707eStholoclose MAIL; 83*43c1707eStholodie "Mail failed" if $?; 84*43c1707eStholo 85*43c1707eStholoexit 0; 86