воскресенье, 25 декабря 2005
имееться
код
use strict;
use IO::File;
my $cvsroot = $ENV{'CVSROOT'};
$) = $(;
my $dostatus = 1;
my $verbosestatus = 1;
my $users;
my $login;
my $donefiles;
my $logfile;
my @files;
#
# parse command line arguments
#
while (@ARGV) {
my $arg = shift @ARGV;
if ($arg eq '-m') {
$users = "$users " . shift @ARGV;
} elsif ($arg eq '-u') {
$login = shift @ARGV;
} elsif ($arg eq '-f') {
($logfile) && die "Too many '-f' args";
$logfile = shift @ARGV;
} elsif ($arg eq '-s') {
$dostatus = 0;
} elsif ($arg eq '-V') {
$verbosestatus = 0;
} else {
($donefiles) && die "Too many arguments!\n";
$donefiles = 1;
@files = split(/ /, $arg);
}
}
my $modulepath = shift @files;
my $mailcmd = "| /usr/sbin/sendmail";
my @mos = (
'January', 'February', 'March',
'April', 'May', 'June',
'July', 'August', 'September',
'October', 'November', 'December'
);
my @days = (
'Sunday', 'Monday', 'Tuesday',
'Wednesday', 'Thursday', 'Friday', 'Saturday'
);
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime;
$year += 1900;
if ($login eq '') {
$login = getlogin || (getpwuid($<
)[0] || "nobody";
}
my $logfh = new IO::File ">>" . $logfile ||
die "Could not open(" . $logfile . "): $!\n";
my $mailfh;
if ($users) {
$mailcmd = "$mailcmd $users";
$mailfh = new IO::File $mailcmd ||
die "Could not Exec($mailcmd): $!\n";
$users =~ s/ /, /;
$mailfh->print ("To: $users\n");
$mailfh->print ("From: unhstack\@mail.ru\n");
$mailfh->print ("Subject: CVS: $modulepath\n");
$mailfh->print ("Content-Type: text/plain; charset=windows-1251\n\n");
}
#
# print out the log Header
#
$logfh->print ("\n");
$logfh->print ("****************************************\n");
$logfh->print ("Date:\t$days[$wday] $mos[$mon] $mday, $year @ $hour:" .
sprintf("%02d", $min) . "\n");
$logfh->print ("Author:\t$login\n\n");
if ($mailfh) {
$mailfh->print ("\n");
$mailfh->print ("Date:\t$days[$wday] $mos[$mon] $mday, $year @ $hour:" .
sprintf("%02d", $min) . "\n");
$mailfh->print ("Author:\t$login\n\n");
}
my $infh = new IO::File "< -";
foreach ($infh->getlines) {
$logfh->print;
if ($mailfh) {
$mailfh->print ($_);
}
}
undef $infh;
$logfh->print ("\n");
#
# after log information, do an 'cvs -Qq status -v' on each file
# in the arguments.
#
if ($dostatus != 0) {
while (@files) {
my $file = shift @files;
if ($file eq "-") {
$logfh->print ("[input file was '-']\n");
if ($mailfh) {
$mailfh->print ("[input file was '-']\n");
}
last;
}
my $rcsfh = new IO::File;
my $pid = $rcsfh->open ("-|");
if ( !defined $pid ) {
die "fork failed: $!";
}
if ($pid == 0) {
my @command = ('cvs', '-nQq', 'status');
if ($verbosestatus) {
push @command, '-v';
}
push @command, $file;
exec @command;
die "cvs exec failed: $!";
}
my $line;
while ($line = $rcsfh->getline) {
$logfh->print ($line);
if ($mailfh) {
$mailfh->print ($line);
}
}
undef $rcsfh;
}
}
$logfh->close() || die "Write to $logfile failed: $!";
if ($mailfh) {
$mailfh->close;
die "Pipe to $mailcmd failed" if $?;
}
exit 0;
почему-то между мейлами юзеров при отправление ставятся точки(
[email protected]@mail.ru и т.п.) =\
в чем может быть проблема?