Okay, another stumper. Every other time I run this script, the Finder returns “missing value” for the free space on the mounted volume (server) “Diamond Design”:
on getVolumeInfo()
set serverName to "Diamond Design"
tell application "Finder"
set capacityRaw to (capacity of disk serverName)
set freeSpaceRaw to (free space of disk serverName)
--convert to gigabytes (GB)
set capacityRawGB to (capacityRaw / 1024 / 1024 / 1024)
set freeSpaceRawGB to (freeSpaceRaw / 1024 / 1024 / 1024)
--
end tell
set gFreeSpace to round_truncate(freeSpaceRawGB, 2)
set gCapacity to round_truncate(capacityRawGB, 2)
end getVolumeInfo
So the first time I click run, I get a value for freeSpaceRaw in scientific notation and all is well.
The second time I click run, I get “missing value” for freeSpaceRaw, and the script fails.
Third time, I get a value.
Fourth time, no value.
.
.
.
rinse-n-repeat
Hi
I adapted your code a little bit and for me it works flawlessly.
Regards
Lazybaer
set MACdisk to “yourID”
set KomSte to 2 – var
set {x, y, z} to getVolumeInfo(MACdisk, KomSte)
on getVolumeInfo(HDx, kmst) – name of volume, decimal positions to round
tell application “Finder”
set cap to ((capacity of disk HDx) / (1024 ^ 3)) – get cap and convert to gigabytes (GB)
set free to ((free space of disk HDx) / (1024 ^ 3)) – get free and convert to gigabytes (GB)
set cap to runde(cap, kmst) of me
set free to runde(free, kmst) of me
end tell
return {cap, free, (cap - free)}
end getVolumeInfo
on runde(val, dec) – variable Rundungsroutine basierend auf ‘round default’
set val to val * (10 ^ dec)
set val to round (val)
set val to val / (10 ^ dec)
return val
end runde
set disks to (list disks)
set MACdisk to choose from list disks
set MACdisk to MACdisk as string
set KomSte to 2 -- var
set {x, y, z} to getVolumeInfo(MACdisk, KomSte)
on getVolumeInfo(HDx, kmst) -- name of volume, decimal positions to round
tell application "Finder"
set cap to ((capacity of disk HDx) / (1024 ^ 3)) -- get cap and convert to gigabytes (GB)
set free to ((free space of disk HDx) / (1024 ^ 3)) -- get free and convert to gigabytes (GB)
set cap to runde(cap, kmst) of me
set free to runde(free, kmst) of me
end tell
return {cap, free, (cap - free)}
end getVolumeInfo
on runde(val, dec) -- variable Rundungsroutine basierend auf 'round default'
set val to val * (10 ^ dec)
set val to round (val)
set val to val / (10 ^ dec)
return val
end runde
set MACdisk to "Diamond Design"
set MACdisk to MACdisk as string
set KomSte to 2 -- var
set {x, y, z} to getVolumeInfo(MACdisk, KomSte)
on getVolumeInfo(HDx, kmst) -- name of volume, decimal positions to round
tell application "Finder"
set cap to ((capacity of disk HDx) / (1024 ^ 3)) -- get cap and convert to gigabytes (GB)
set free to ((free space of disk HDx) / (1024 ^ 3)) -- get free and convert to gigabytes (GB)
set cap to runde(cap, kmst) of me
set free to runde(free, kmst) of me
end tell
return {cap, free, (cap - free)}
end getVolumeInfo
on runde(val, dec) -- variable Rundungsroutine basierend auf 'round default'
set val to val * (10 ^ dec)
set val to round (val)
set val to val / (10 ^ dec)
return val
end runde
show a little initiative. also, how about a “THANK YOU” to the people that post to help you? comments like:
and,
are the kind of terse language you might use with a coworker who knows you well and that you don’t mean anything by it. be polite and you’ll find people are much more willing to help.
Actually, my first examination of both scripts had me scratching my head, since they didn’t look any different than mine except in philisophy of coding. So I used it verbatim on the chance I missed a detail. So I would appreciate you not accusing me of a lack of initiative in this instance.
I appreciate your commentary. Generally I would thing a “Thank you” comes after the solution is, well, solved. Or, a “thank you for trying” if things just don’t pan out after a few days. I considered this all still “mid discussion” stuff since it hasn’t worked yet.
Personally, my assumption is we’re all adults here and the atmosphere is assumed friendly (at least it was by me until this happened). Had no reason to consider anyone here hostile, didn’t figure there was any reason for anyone else to either.
shrug
But for all involved, I do appreciate the help so far, and I am using the examples verbatim if possible before modifying them too much. And I sincerely apologize if someone was offended by my feedback.
sorry if i came off rude, but i do feel that you could give better feedback and be a little nicer to the posters.
even posting the above is a help to a troubleshooter who isn’t in your situation, and is only able to read about it on a board. the steps you use to validate (or not) a script are really good feedback.
do you know the old saying about, “assuming”?
i’ve run each of the code versions here on a G4 running 10.4.5 against a win2k3 server sharing with services for Macintosh, and it works each time i run it from within the “Script Editor” and have the “Result” tab highlighted. do you think it would be helpful to post this kind of information about your situation or do you think this is all just in AppleScript? you may want to post how you are accessing the output or something so others can test it too. i’ll confess that i may not have the solution for you, but at least one poster has said this is a bug, so it could be related to the OS version, AppleScript version, OS of the network share.
Called dialog, and I think we got there this time around.
Well, yes, but I’m a firm believer in assuming the best, prepare for the worst. I tired long ago of catering to the prevelant reaction to the opposite. If folks want to assume the worst with no prior context for it, that’s their issue.
That being said, I hope now you can assume I’m not out to eat everyone? Dry wit, sarcastic, clinical…guilty as charged. I don’t know enough about AppleScript to be arrogant in this context however.
I’m doing it against an OS X (Panther) server, if that helps. that is, I’m on a local workstation getting the information from a mounted volume named “Diamond Design.”
I agree I had no considered the problem may lie with the server. Odd, but I wouldn’t be surprised. I was rather hoping since it was so predictable (every other script run) that it was some goof in my AppleScript.
On the “more details” note, I tried to trick AppleScript into using “try” to capture the first “missing data” response then re-run to get the number, but apprently the problem (or bug) requires the entire script to be re-run the second time, not just the call for data itself.
Well, that’t just it…the problem lies with the data call…every other time it returns “missing value” even if run in isolation.
Well I didn’t want to spam the forum, but I can post the entire routine if y’all like. It’s 347 lines of code/comments though. Unfortunately even if I give the enclosing handler, it’s out-of-context for the casual observer. Only the entire shooting match gives it proper context.
The gist is that the script grabs information from the server free space once per night and logs it to an Excel spreadsheet. The idea is eventually to also get it to re-create a graph in Excel as well. Lastly, a file is placed on the server whose filename is an update on free space to not-so-subtly remind users how much space they are hogging up. The goal, to examine server usage trends over time.
(There is a “long form” version of this story, but not sure how much detail ya want…)
Well, in the end since the “bug” was 100% repeatable, since the free space on the volume returned “missing value” every other time it was queried via script, I opted to:
–Trap the initial data gathering. If free space on the volume came back as “missing value” then a global bug flag was set to “yes”
–All apsects of the script calling on that value were then placed insides “if” statements so as not to execute if the bug flag was “yes”. With the bug flag at “yes” the script essentially does nothing (makes a log entry so I know it fired off and trapped the bug).
–The script is set to fire off twice every night, knowing that at least one of the executions will get a value and perform the necessary scripted tasks.
Bit of a hack, but reliable. Wonder if Apple is aware of this oddity.
Very grateful for those that attempted to help, great folks participating here at MacScripter.
Here’s what I have - I just consolodated a few lines…
set serverName to "Macintosh HD"
tell application "Finder"
set capacityRaw to ((capacity of disk serverName) / 1024 / 1024 / 1024) as integer
set freeSpaceRawGB to ((free space of disk serverName) / 1024 / 1024 / 1024) as integer
end tell