469,330 Members | 1,354 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,330 developers. It's quick & easy.

how to check windows disk space using perl

4
Hello All,

I need to find disk space on one of my drives in windows machine using perl. But, I cant seem to find windows command that I can script.

I have performed similar task for unix machine using system call and then parsing the data obtained.

system("df -k");

Does anyone know any similar command for windows?

Thanks.
Jan 21 '08 #1
6 13783
eWish
971 Expert 512MB
Welcome to TSDN!

Have a look at Win32::DriveInfo at CPAN.

--Kevin
Jan 21 '08 #2
nb999
4
Thank You Kevin for your quick reply. But, I am relatively new to perl and cant seem to install this perl module.

I get the following error when I run the script containing this module
Can't locate Win32/API/Type.pm in @INC (@INC contains: C:/Perl/site/lib C:/Perl/
lib .) at C:/Perl/site/lib/Win32/API.pm line 31.
BEGIN failed--compilation aborted at C:/Perl/site/lib/Win32/API.pm line 31.
Compilation failed in require at C:/Perl/site/lib/Win32/DriveInfo.pm line 5.
BEGIN failed--compilation aborted at C:/Perl/site/lib/Win32/DriveInfo.pm line 5.

Compilation failed in require at C:\find_drive_space.pl line 3.
BEGIN failed--compilation aborted at C:\find_drive_space.pl line 3.

code:

#!/usr/bin/perl

use Win32::DriveInfo;

($SectorsPerCluster,
$BytesPerSector,
$NumberOfFreeClusters,
$TotalNumberOfClusters,
$FreeBytesAvailableToCaller,
$TotalNumberOfBytes,
$TotalNumberOfFreeBytes) = Win32::DriveInfo::DriveSpace('c');

$TotalNumberOfFreeBytes = (Win32::DriveInfo::DriveSpace('c:'))[6];



print"Free disk space available in C drive is $TotalNumberOfFreeBytes\n";


I seem to be very close. Thanks once again.
Jan 21 '08 #3
eWish
971 Expert 512MB
I am assuming that you are on a Windows machine. If you are using ActiveState perl then you can use the PPM utility.

--Kevin
Jan 22 '08 #4
KevinADC
4,059 Expert 2GB
at the DOS prompt type

dir /?

and you should get a list of the dir command and options
Jan 22 '08 #5
nb999
4
Thanks Moderator and Kevin. I am going to try pm as I have spent some time on it. The dos prompt option looks good too and would try it.

Thanks.
Jan 22 '08 #6
KevinADC
4,059 Expert 2GB
It's an old module, so I would make sure it's spitting out good numbers before using it for anything important.
Jan 23 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Thomas Schulz | last post: by
20 posts views Thread by David | last post: by
2 posts views Thread by Anthony Paul | last post: by
9 posts views Thread by Jon LaBadie | last post: by
1 post views Thread by rcamarda | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Purva khokhar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.