471,881 Members | 1,370 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,881 software developers and data experts.

how to check windows disk space using perl

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?

Jan 21 '08 #1
6 14033
971 Expert 512MB
Welcome to TSDN!

Have a look at Win32::DriveInfo at CPAN.

Jan 21 '08 #2
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.



use Win32::DriveInfo;

$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
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.

Jan 22 '08 #4
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
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.

Jan 22 '08 #6
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 YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.