TeraMarv has asked for the wisdom of the Perl Monks concerning the following question:
All tests result in undefined arrays.use strict; use Win32::DriveInfo; use Win32::AdminMisc; use Data::Dumper; ################# my $target = '\\\\server\\c\\'; my @diskinfo = Win32::DriveInfo::DriveSpace($target); print Dumper \@diskinfo; ################# @diskinfo = Win32::AdminMisc::GetDriveGeometry($target); print Dumper \@diskinfo; exit 0;
use strict; use Win32::DriveInfo; use Win32::NetAdmin; use Data::Dumper; my $capacity_href; my @servers = ('hqteradcm1','hqteradcm2','hcodevj248'); for my $server (@servers) { my @disks; my $target = '\\\\'.$server.'\\'; # Find all drives on server $target Win32::NetAdmin::GetServerDisks($target, \@disks); # Change array elements from C: to \\\\server\\c$\\ map { s/(.*):/$target\L$1\$\\/; } @disks; for my $drive (@disks) { # Find drive types my $type = Win32::DriveInfo::DriveType($drive); # Test for valid drive types - if($type =~ /(?:3|4)/) { # Find total and free space on drive my ($total,$free) = (Win32::DriveInfo::DriveSpace($driv +e))[5,6]; $drive =~ s/^\\\\.*\\(.)\$\\/\U$1:\//; $capacity_href->{$server}->{$drive} = { total => $total +, free => $free }; } } } print Dumper $capacity_href; exit 0;
---------- Capture Output ---------- > "C:\Perl\bin\wperl.exe" DriveSpace.pl $VAR1 = { 'hqteradcm1' => { 'E:/' => { 'free' => '10177232896', 'total' => '18449301504' }, 'C:/' => { 'free' => 3358816256, 'total' => '18457527808' } }, 'hcodevj248' => { 'E:/' => { 'free' => '5279924224', 'total' => '18449301504' }, 'C:/' => { 'free' => '11348357632', 'total' => '18457527808' } }, 'hqteradcm2' => { 'E:/' => { 'free' => '16571375616', 'total' => '36964372480' }, 'C:/' => { 'free' => 718196224, 'total' => '8595417088' }, 'F:/' => { 'free' => '26558570496', 'total' => '28311412736' } } }; > Terminated with exit code 0.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Finding Drive usage info with Win32
by GrandFather (Saint) on May 17, 2006 at 03:55 UTC | |
by TeraMarv (Beadle) on May 17, 2006 at 04:12 UTC | |
|
Re: Finding Drive usage info with Win32 ($^E?)
by tye (Sage) on May 17, 2006 at 04:17 UTC | |
by bobf (Monsignor) on May 17, 2006 at 04:44 UTC | |
by tye (Sage) on May 18, 2006 at 06:06 UTC | |
by TeraMarv (Beadle) on May 17, 2006 at 04:34 UTC | |
|
Re: Finding Drive usage info with Win32
by Discipulus (Canon) on May 17, 2006 at 07:11 UTC |