chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Getting disk space


From: Zbigniew
Subject: Re: [Chicken-users] Getting disk space
Date: Tue, 18 Dec 2007 21:13:09 -0600

Normally I use the output of df when writing a system script.  The
statfs approach looks good too.  Here's an example of grabbing output
from df on Linux.  The main issue is dealing with platform-dependent
output and command-line options.  Below I used the -P flag because on
Linux it ensures there is no line-wrapping.

(use posix match)
(with-input-from-pipe "/bin/df -P"
  (lambda ()
    (read-line)     ; skip header
    (for-each-line
     (lambda (line)
       (match-let (((fs blocks used avail capacity mount)
                    (string-split line)))
         (print "Mount point " mount ", "
                (* (string->number avail) 1024)
                " bytes available."))))))

;; output
Mount point /, 134206464 bytes available.
Mount point /lib/init/rw, 264638464 bytes available.
Mount point /dev, 9891840 bytes available.
Mount point /dev/shm, 264638464 bytes available.
Mount point /usr, 383954944 bytes available.
Mount point /var, 632696832 bytes available.
Mount point /home, 2397798400.0 bytes available.
Mount point /scratch, 5539717120.0 bytes available.



On Dec 18, 2007 3:07 PM, William Ramsay <address@hidden> wrote:
> Hi,
>
> Can anyone tell me how I can get available disk space from a chicken
> program.   I want the same results you get with df in linux.   If the
> answer is using process or open-input-pipe.etc. and actually running df
> please explain how this is done since I cannot get it to work no matter
> what I do.
>
> If there is a way of duplicating df in code - even in c - I would
> appreciate that as well.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]