#! /usr/bin/env perl # Reads output of rsync -v --stats command which has been redirected to a "log file" # and returns a summary on STDOUT # accepts one or two parameters which are positional # First parameter is the exit code from rsync (uses 0 if not given) # Second parameter is the name of the log file (uses STDIN if not given) # Returns result as a human readable summary in the form specified by $OUTPUT_FORMAT use warnings; use strict; require "rsbackup.pm"; # get the rsync return code from the command line my $rsyncReturn = shift; $rsyncReturn = 0 unless defined $rsyncReturn; my $inputFile = shift; # if the input file name was passed on the command line, process it. Otherwise, process STDIN if ($inputFile) { open $fh, "<$inputFile" or die "could not open $inputFile for read: $!"; } else { $fh = *STDIN; } print &summarizeRsyncLog( $fh, $rsyncReturn ); close $fh; 1;