Thanks for these replies, when I get the chance (suddenly I'm a bit snowed under) I'll have a look into the solutions people have offered and - if I'm successful - post a followup. Ian ---------- >From: Chris Nandor <pudge@pobox.com> >To: "Jefferson R. Lowrey" <lowrey@mailbag.com> >Subject: Re: [MacPerl] Determining free disk space >Date: Mon, Oct 11, 1999, 4:40 pm > > At 8:55 -0500 1999.10.11, Jefferson R. Lowrey wrote: >>At 10:34 AM +0200 10/11/99, Ian wrote: >>>Hi >>> >>>I've had a look at CPAN, the FAQ, and searched the mailing list archive, but >>>with no joy. I'd like to write a simple script that runs as a cron job and >>>checks the space remaining on all the volumes on our server...if there's >>>less than a certain amount of space on one of the volumes it'll email the >>>sysadmin with the details. >>> >>>However, I can't find a way of finding out how much free space there is on a >>>mounted (or local) volume. There are a couple of Unix modules for this, but >>>evidently not for the Mac. Any clues? >>> >> >>Well. This sounds like a job for glue... >>use strict; >>use Mac::Glue ':all'; >>my $finder = new Mac::Glue 'Finder'; >> >>my $freespace = $finder->get($finder->prop('free_space',disk => 'Jeff-HD')); >> >>print "$freespace\n"; >>__END__ >> >>But I'm not getting quite the result I'm looking for. It sends the same AE >>as the corresponding AppleScript (another option) >>tell application "Finder" >> get free space of disk "Jeff-HD" >>end tell >> >>but I get a result like >>comp(«0000000017402000») >> >>So I don't think I'm coercing things right or using the right terminology >>somewhere. > > There are two ways around it. > > One is to add this code: > > local $Mac::AppleEvents::Simple::AE_GET{comp} = sub { > (unpack 'll', shift()->data->get)[-1] > }; > > This will unpack the double integer (which is what 'comp' stands for, I > believe). I can add this code to a future version of the module or > something. > > The other way is to ask for a double float: > > printf $finder->get( > $finder->prop(free_space => disk => 'Bird'), > as => 'doub' > ); > > You can also do: > > $Mac::Types::MacUnpack{comp} = sub { > (&Mac::Types::_Unpacker('ll')->(@_))[-1]; > }; > > Note that we take the last argument of the list returned by the two > unpacking routines. I guess you should really concatenate the two values: > > join '', unpack 'll' ... ; > > Would that be correct? But if you did that, you could not use the > resulting number for math operations (unless the first number is 0, which > it will be in most cases). > > -- > Chris Nandor mailto:pudge@pobox.com http://pudge.net/ > %PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6']) # ===== Want to unsubscribe from this list? # ===== Send mail with body "unsubscribe" to macperl-request@macperl.org