#!/usr/bin/perl # | cronmail address 'email subject' # # if cron job's output has nonwhitespace characters, it'll email the # output to that address, otherwise it'll do nothing # # Contributions/suggestions/bugs to: Ofer Inbar # # Written at, and donated to the community by, Going.com # All my scripts distributed under the terms of Larry Wall's excellent # Artistic License: http://language.perl.com/misc/Artistic.html my $cmd = '/usr/sbin/sendmail'; my $adr = shift; my $subject = shift; chomp(my $host = `hostname`); $host=~s/\..+$//; my ($sec,$min,$hour) = localtime(time); my $time = sprintf "%02d:%02d",$hour,$min; my @lines = <>; if (grep (/./, @lines)) { open MAIL, "| $cmd $adr" or die "$0: can't run $cmd $adr: $!\n"; $subject .= ": " if $subject; chomp($subject .= $lines[0]); print MAIL <