Thanks to all the input. I learned... what more I have to learn. Here
is the final working perl script that sends the current "df -mg"
command to a text file for daily logging.
-David
#!/usr/bin/perl -w
use strict;
use warnings;
my $dayStamp = do {
my ( $day, $month, $year ) = ( localtime )[ 3, 4, 5 ];
sprintf '%02d%02d%02d', $year % 100, $month + 1, $day;
};
my $fileName = "$dayStamp"." diskSpace.txt";
my $fileLoc = "/Users/mini/diskSpaceLog/diskSpaceLog/$fileName";
open my $PIPE, '-|', 'df', '-mg' or die "Cannot open pipe from 'df' $!";
open my $FH, '>', $fileLoc or die "Cannot open '$fileLoc' $!";
while ( <$PIPE> ) {
print $FH $_;
}
close $PIPE or warn $! ? "Error closing df pipe: $!"
: "Exit status $? from df";
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/