balakrishnan has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I wanted to get disk space details of a windows drive like free, used and available. The total size of the drive is like 8TB, used 5.56TB and free 1.78TB. Attempted with Filesys::Diskspace and Filesys::DfPortable, it gives me wrong results as seems like there is a limitation on handling disk size(i.e: max of integer 4 byte value).
The wrong usage details given for the drive as :
Total bytes: 41943035904
Total bytes free: 17095663616
Total bytes avail to me: 17095663616
Total bytes used: 24847372288
Please suggest me the other respective ways that supports in all higher version of Windows 2000 OS.
Thanks,
Bala.
Re: get disk usage details like free, used, available for windows drives with sizes in TB
by jellisii2 (Hermit) on Jan 06, 2014 at 14:10 UTC
|
a quick google turns up Win32::DriveInfo.
You can use sniff for determining if you need to use it (or a *nix counterpart like you're trying to use) or not. Re: cross platform scripts has a very rudimentary version of it demonstrated. | [reply] |
Re: get disk usage details like free, used, available for windows drives with sizes in TB
by soonix (Canon) on Jan 06, 2014 at 10:46 UTC
|
`wmic logicaldisk where DriveType="3" get /format:csv`
using Text::CSV. If you don't want to exclude optical drives, mounted shares, etc, you can leave off the where DriveType="3" part. | [reply] [d/l] [select] |
|
Thanks you so much for your comments..
The concern here is, Windows 2000 doesnt support wmic.
I am just looking for the solution which should work in all Windows OS >= Windows 2000.
| [reply] |
|
C:\Windows\System32>fsutil volume diskfree c:
Total # of free bytes : 143714562048
Total # of bytes : 627247673344
Total # of avail free bytes : 143714562048
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] |
|
|
|
|
|
Select DeviceID,Size,FreeSpace from Win32_LogicalDisk
| [reply] [d/l] |
|
| [reply] |
Re: get disk usage details like free, used, available for windows drives with sizes in TB
by dasgar (Priest) on Jan 06, 2014 at 14:21 UTC
|
I'd recommend checking out Win32::DirSize. I've been able to use it on Windows Server 2008 without issue.
| [reply] |
Re: get disk usage details like free, used, available for windows drives with sizes in TB
by BrowserUk (Patriarch) on Jan 08, 2014 at 12:18 UTC
|
Looking at the XS/source for Filesys::DfPortable it should return the correct values, even on 32-bit perl's that do not have 64-bit integer support. It achieves that by returning the numbers as ascii strings.
The likely reason you are getting incorrect results displayed is that you are using printf with a "%d" format?
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |
Re: get disk usage details like free, used, available for windows drives with sizes in TB
by RyuMaou (Deacon) on Jan 08, 2014 at 15:04 UTC
|
| [reply] |
|
|