Benutzerbericht - ein Perl-Script

Dieses kleine Perl-Script gibt den von Benutzern eines UNIX-Systems verbrauchten Plattenplatz aus.

#!/usr/bin/perl
# show used discspace

$|=1;
my %groups;

open IN,"/usr/bin/ypcat group | sort |";

while ()
{
    chop;
    ($groupname,$pw,$gid,$members) = split ":",$_;
    $groupname{"$gid"} = $groupname;
    foreach $user (split ",",$members)
    {
         $his_groups{$user} .= ",".$groupname;
    }
    $groupname{$gid} = $groupname;
}

open IN,"/usr/bin/ypcat passwd | grep home_wol | sort |";

while ()
{
    chop;
    ($user,$pw,$uid,$gid,$info,$home,$shell) = split ":",$_;
    ($name,$location,$tel,$add) = split ",",$info;
    $his_groups{$user} = $groupname{$gid} . $his_groups{$user};
    if ($pw ne "NOLOGIN") {$pw = "";} else {$pw = "DISABLED";}
    
    printf "%-10s",$user;
    printf "%-30s",$name;
    printf "%-19s",$home;
   
    if (-d $home) {
        open DU,"du -sk $home |";
        $in = ;
        chop $in;
    } else {
        $in = "NONE";
    }

    ($size,$dirname) = split /\W+/,$in;
    printf "%+10s",$size;
    printf " %-10s",$pw;
    print "\n";
}

Alle Touren

Schneebergwege

Raxsteige

Geführte Touren

Perl

Literatur

Musik