PIKT

Samples: Show User Disks

PIKT Logo
Home FAQ News Intro Samples Tutorial Reference Software Authors Licensing SiteSearch


This showdisks_programs.cfg example defines a simple Perl script to show user disks.
///////////////////////////////////////////////////////////////////////////////
//
// showdisks_programs.cfg
//
///////////////////////////////////////////////////////////////////////////////

showdisks.pl    // show a system's user disks

        #!=perl
        
        # showdisks.pl -- show a system's user dirs
        
        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, "=dfk | =grep '^/dev/' |") ;
#fix
        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)) ;
#if backupserver
                next if (($mnt =~ /^\/(amanda\/disk|db2data)$/) && ! $ALL) ;
#endif
                #next if (! $BAK && ! $USR) ;
                print "$mnt\n" ;
        }
        close(DF) ;
#unfix

///////////////////////////////////////////////////////////////////////////////
On the piktmaster system, we would install the showdisks.pl script to each PIKT slave system with the command:
# piktc -iv +P showdisks.pl +H all        [or: ... -H downsys]

[For more examples, see Samples.]

Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software | Authors | Licensing | SiteSearch
Links | SiteIndex | Pikt-Users | Pikt-Workers | Contribute | ContactUs | Top of Page
Page best viewed at 1024x768.   Page last updated 2005-06-22.
This site is PIKT® powered.
PIKT® is a registered trademark of the University of Chicago.
Copyright © 1998-2005 Robert Osterlund.  All rights reserved.

Computer Books at Amazon.com

Perl Debugger Pocket Reference
Perl Debugger Pocket Reference

Perl Cookbook
Perl Cookbook

Minimal Perl: For UNIX and Linux People
Minimal Perl: For UNIX and Linux People

Learning Perl/Tk: Graphical User Interfaces with Perl
Learning Perl/Tk: Graphical User Interfaces with Perl

Higher-Order Perl: Transforming Programs with Programs
Higher-Order Perl: Transforming Programs with Programs