use strict;
use warnings;
####
#Checks the type of OS here
$OS = `uname -s`;
print ("The Operating System is $OS");
if ($OS == SunOS ) {
&< snip1 &<
####
my $os = `uname -s`; # why capital?
chomp $os; # get rid of the EOL character, you'll be glad you did.
printf "Operating system: %s\n",$os;
if ( $os eq 'SunOS' ) { # this is where EOL needs to be gone...
&< snip! &<
####
$DF = `df -h $FILESYSTEM | grep -v "Filesystem" | sed -e "s/%//g"|
+awk '{print $5}'`;
print ("The file system $ FILESYSTEM usage is $DF % \n");
####
my $cmd=sprintf("df -k %s |",$FILESYSTEM) #note the trailing pipe in the format
open PIPE,$cmd or die "$cmd: $!";
my $junk=; # get rid of the first line.. it's junk.
#
# Could probably use /[\s]+/ but...
my @df=split(/[\s\n\t]+/,)
close PIPE; # done with this.
my $df=$df[4]; #keep in mind the scalar $df is different than the array @df
chomp $df; # just for grins
$df =~ s/\%//g; # strip the %
printf "File system %s is %d%% used\n",$FILESYSTEM,$df
####
$DU = `du -sh $FILESYSTEM | sort -rn | head -20`;
####
open PIPE, sprintf("du -s %s/* |,$FILESYSTEM) or die $!;
my @raw=;
chomp @raw;
my @summary=();
foreach my $line(@raw){
my($blocks,$subdir)=split(/[\s+]/,$line);
push @summary,{
blocks=>$blocks,
subdir=>$subdir
};
}
@summary=sort {
$b->{blocks} <=> $a->{blocks}
} @summary;
printf "%s\n",join("\n",
map {
sprintf("%d\t%s",$_->{blocks},$_->{subdir})
} @summary[0..19]
);