Show User Disks

In this simple showdisks.pl Perl script, we show user disks.  This script is referenced by the dirs_user_objects.cfg configuration file, and sources from the showdisks_programs.cfg file.

#!/usr/bin/perl

# showdisks.pl -- show a system's user disks

use Getopt::Std ;
die "Usage:  showdisks.pl [-a|-b|-s|-u]\n" if (! getopts('absu') &&
                                               ($#ARGV != 0)) ;
$ALL = $opt_a ;
$BAK = $opt_b ;
$SYS = $opt_s ;
$USR = $opt_u ;

open(DF, "/usr/bin/df -k | /usr/bin/grep '^/dev/' |") ;
while(<DF>) {
        chomp ;
        next if ($_ !~ /^(\S+)\s+\S+\s+\S+\s+\S+\s+\S+\s+(\S+)$/) ;
        $dev = $1 ;
        $mnt = $2 ;
        next if ($dev eq "/proc") ;
        next if ($mnt =~ /^\/floppy/) ;
        next if (($mnt =~ /^\/swap.?/) && ! $ALL) ;
        next if (($mnt =~ /^\/cdrom/) && ! $ALL) ;
        next if (($mnt =~ /^\/(usr||opt|var|tmp)$/) &&
                 (! $ALL && ! $BAK && ! $SYS)) ;
        next if (($mnt =~ /^\/var\/mail/) && (! $ALL && ! $SYS)) ;
        next if ((($mnt =~ /^\/home\//) && ($mnt !~ /^\/home/)) &&
                 (! $BAK && ! $USR)) ;
        #next if (! $BAK && ! $USR) ;
        print "$mnt\n" ;
}
close(DF) ;

Open Hand For more examples, see Samples.

 
Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software
Developer's Notes | Licensing | Authors | Pikt-Users | Pikt-Workers | Related Projects | Site Index | Privacy Policy | Contact Us
Page best viewed at 1024x768 or greater.   Page last updated 2008-03-27.   This site is PIKT® powered.
PIKT® is a registered trademark of the University of Chicago.   Copyright © 1998-2008 Robert Osterlund. All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title
View sample
inode shortages
Pikt script