473,383 Members | 1,862 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,383 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 14367
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.