meraxes has asked for the wisdom of the Perl Monks concerning the following question:

I have what would seem to me to be a very simple question, but I've not found any answer in my searching.

If one wishes to determine the amount of disk space remaining, it appears that using backticks and capturing the output of something like 'dir' (sorry, I'm a win32 user...) is the way to go. Is there a module or core perl function that can do this (specifically, platform independant) way of determining how much space is left? I found plenty that will tell me how much is used, but not the 'remaining' space.

Many thanks,
|\/|eraxes

Replies are listed 'Best First'.
Re: Remaining Diskspace
by Marza (Vicar) on Jun 17, 2002 at 22:27 UTC

    I put something in the Code Catacombs. It is a small script that checks free space, used, etc. for a domain. Feel free to use and abuse it anyway you see fit.

    Domain Disk space check
Re: Remaining Diskspace
by gumby (Scribe) on Jun 17, 2002 at 20:50 UTC
    To my knowledge, there are several modules that can handle this for you; Win32::DriveInfo is but one.

    Update: I just noticed you specified platform independent, so you probably mean a Unix 'df' equivalent. There are also a couple of modules on CPAN which will provide this function.

      I'd already found Filesys::DiskFree but it only works for *nix OS's. I was hoping for a module that could make the determination on both Win32 and MacOSX... doesn't seem to be one though. I guess there'll have to be two versions of the script.

      Disappointing but I suppose it's not too surprising. Since each OS uses different file systems I guess it'd be pretty difficult to write one module for all OS's.

      Thanks for the info though, I'm sure I'll be able to use it somewhere else in the future.

        I thought I would just note that while Filesys::Df is not portable to the Windows environment, it is highly portable between *NIX platforms, providing a better means (IMHO) by which to check available disk space (via a statvfs call) on these platforms than parsing the output of df - An example of the usage of this module and a discussion on its merits over the parsing of the output of df can be found here.

         

A reply falls below the community's threshold of quality. You may see it by logging in.