Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

get disk usage details like free, used, available for windows drives with sizes in TB

by balakrishnan (Monk)
on Jan 06, 2014 at 07:06 UTC ( #1069464=perlquestion: print w/ replies, xml ) Need Help??
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.

Comment on get disk usage details like free, used, available for windows drives with sizes in TB
Re: get disk usage details like free, used, available for windows drives with sizes in TB
by soonix (Curate) on Jan 06, 2014 at 10:46 UTC
      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.

        Try this:

        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.

        Another option, you could use DBD::WMI with the following query:

        Select DeviceID,Size,FreeSpace from Win32_LogicalDisk
Re: get disk usage details like free, used, available for windows drives with sizes in TB
by jellisii2 (Friar) 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.

Re: get disk usage details like free, used, available for windows drives with sizes in TB
by dasgar (Deacon) 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.

Re: get disk usage details like free, used, available for windows drives with sizes in TB
by BrowserUk (Pope) 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.
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1069464]
Approved by Corion
Front-paged by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2014-09-21 19:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (175 votes), past polls