From: Edwin van Leeuwen Date: 2006-05-19T23:54:36+09:00 Subject: Re: Disk Free Space (Re: Who Wants to Be a Scripting Guy?) Paul Knight wrote: > On May 19, 2006, at 12:43 AM, Alex Young wrote: > >> Dave Burt wrote: >> >> On unices, I think this does the trick: >> >> $ df -h `mount | grep '^/dev' | cut -f 3 -d ' '` >> >> Works on Linux and OS X, certainly - I don't have any other BSDs to >> check. > > It should work on most modern *nix systems, but `df -h` isn't > available on Solaris 8 and older. Incidentally, this was one of my > favorite changes in Solaris 9. > > Paul Knight I found a ruby version of df a long time ago. It did a syscall(99), so if this syscall is a standard POSIX one then the script should work on all posix compliant os-es The relevant part: size = 64 unpack_fmt = 'iiiiiiiiiiiiiiii' foo = ' ' * size syscall(99, hd[1], foo) type, @bsize, @blocks, @bfree, @bavail, @files, @ffree, tmp,tmp,@namelen = foo.unpack(unpack_fmt) usage=100*(@blocks-@bfree)/@blocks -- Posted via http://www.ruby-forum.com/.