use Win32::DriveInfo;
use constant {
SECTORS_PER_CLUSTER => 0,
BYTES_PER_SECTOR => 1,
FREE_CLUSTERS => 2,
TOTAL_CLUSTERS => 3,
BYTES_FREE_4_CALLER => 4,
TOTAL_BYTES => 5,
TOTAL_FREE => 6,
};
#$sql = "\\\\server01\\d\$";
$sql = "c:";
print "$sql\n";
print "Drive Free Tot PctFree\n";
my @info = Win32::DriveInfo::DriveSpace($sql) ;
print "$^E\n";
# or die "DriveSpace failed with error: $^E";
printf "%.3f GB free of total %.3f GB\n",
$info[ TOTAL_FREE ] / 1000**3,
$info[ TOTAL_BYTES ] / 1000**3;
####
c:\Perl>drivelist.pl
\\sql-01\d$
Drive Free Tot PctFree
0.000 GB free of total 0.000 GB
c:\Perl>drivelist.pl
c:
Drive Free Tot PctFree
The specified procedure could not be found
31.283 GB free of total 74.444 GB
c:\Perl>dir
Volume in drive C is cMore
Volume Serial Number is A07E-ED9D
Directory of c:\Perl
02/18/2010 10:59 PM .
02/18/2010 10:59 PM ..
05/30/2008 03:51 PM bin
05/30/2008 03:51 PM eg
05/30/2008 03:51 PM etc
05/30/2008 03:52 PM html
05/30/2008 03:51 PM lib
05/30/2008 03:51 PM man
05/30/2008 03:51 PM site
02/18/2010 10:58 PM 629 drivelist.bak
02/18/2010 10:59 PM 628 drivelist.pl
2 File(s) 1,257 bytes
9 Dir(s) 33,590,083,584 bytes free
####
c:\Perl>perl -v
This is perl, v5.10.0 built for MSWin32-x86-multi-thread
(with 5 registered patches, see perl -V for more detail)
Copyright 1987-2007, Larry Wall
Binary build 1003 [285500] provided by ActiveState http://www.ActiveState.com
Built May 13 2008 16:52:49