diskinfo.pl Skriptík na výpis a uložení informací o discích

#! /usr/bin/perl  
# basinfo - Basic info of this machine
# jako argumenty nazvy disku, napr: hda hdd
 
print `date`;
 
open (HOSTNAME, "/etc/hostname");
$hostname = <HOSTNAME>;
close HOSTNAME;
print "hostname: $hostname\n";
 
foreach $disk(@ARGV)
{
 &diskinfo ("/dev/$disk");
}

###################################################################

sub cmd
{
local ($cmd) = @_;
print "$cmd\n";
print `$cmd`."\n";
print "\n";
}

sub diskinfo
{
 local ($disk) = @_;
 &cmd ("sfdisk -lV $disk");
 &cmd ("fdisk -l $disk");
 &cmd ("fdisk -lu $disk");
 &cmd ("echo -e \"x\\np\\nq\" | fdisk $disk");
 
# my $partlist = `sfdisk -l /dev/hda | grep '^/dev/' | awk '{print $1}'`;
 my $partitions = `sfdisk -l $disk`;
 my @partlist = split ( "\n", $partitions);
 @partlist = grep (m|^/dev/|, @partlist);
 for $partline (@partlist) {
    my ( $part ) = split( /\s/, $partline );
#    print "$partline\n"; 
#    print "$part\n"; 

 &cmd ("dumpe2fs $part");
 }
} 

sub dopen       # open or die
{
# local (HOSTNAME, $name) = @_;
 open (HOSTNAME, $name) || die("Nemůžu otevřít soubor $name!");
}