473,390 Members | 1,418 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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 14369
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

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

Similar topics

6
by: Thomas Schulz | last post by:
Any ideas how to check for free disc space from Python. Platform independent? Thanks for any suggestion. Thomas
20
by: David | last post by:
I have seen postings that indicate some developers are creating PHP apps for a Windows server environment. I am not sure if they run underr IIS or Apache, but I wonder why Windows and PHP vs. the...
0
by: MLH | last post by:
The following site has a copy of mdacsdk.exeon it....
2
by: Anthony Paul | last post by:
Hello, Not sure if this is the correct group for this post, but here goes. I have an NT4 PDC acting as a file and print server. No other applications installed on it. With over 300MB on the...
9
by: Jon LaBadie | last post by:
Suppose I'm using stdio calls to write to a disk file. One possible error condition is no space on file system or even (in unix environment) a ulimit of 0 bytes. Which calls would be expected to...
0
by: Jas Shultz | last post by:
I'm using Win2K3 Enterprise edition with the latest .NET framework installed. I have this problem with getting "out of disk space" errors. It doesn't happen all the time but it does happen. When...
1
by: rcamarda | last post by:
Hello, I have an EM Job script that backups up my databases using SQLsafe to a target UNC. Sometimes, the target server that will store the backups is off line or it's disk is full. I am...
10
by: kevinliu23 | last post by:
HI, I am new to Python and wanted to know how to check for the remaining disk space on my Windows machine using Python? I was thinking of using the command line "dir" and trying to extract the...
0
by: trazcure | last post by:
Hi everyone, my name is Traz I'm trying to write some C# code that will check for remote disk space on network shares. I have seen across the internet and MSDN that you can utilize the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.