#!/usr/local/bin/perl -w # # Silly program which shows using this module # use strict; use Filesys::DiskFree; # Create a new handle my $df = new Filesys::DiskFree; # Set the modes $df->set('-mode'=>'blocks'); $df->set('-format'=>'solaris'); # Remember what format we're using print $df->set('format'),"\n"; # Load a scalar with the right values. my $line= <load($line); # Some prints of info print $df->device('/dev/hdc1')." is mounted on ".$df->mount('/dev/hdc1')."\n"; $df = new Filesys::DiskFree; $df->set('-mode'=>'blocks'); $df->set('-format'=>'bsdos'); $line= <load($line); print $df->device('/home')." is mounted on ".$df->mount('/home')."\n"; # Start again, create another new handle $df=new Filesys::DiskFree; # This time we're using a file handle. This is a silly example, # because you could do the same thing with just the df() method, # but you could use rsh or some similar method to do this on a # remote machine my $cmd=$df->command(); open(DF,"$cmd|") or die "Cannot $cmd $!\n"; $df->load(\*DF); close(DF) or die "Cannot $cmd $! $?\n"; # Now output the disks my @disks=$df->disks(); print join(" ",@disks); print "\n"; # Finally, output the # of free inodes on / $df=new Filesys::DiskFree; $df->set('-mode'=>'inodes'); $df->df(); print "Disk ".$df->device('/')." has ",$df->avail('/')," inodes available\n";