Re: Hdiutil broken for me
Re: Hdiutil broken for me
- Subject: Re: Hdiutil broken for me
- From: Sander Tekelenburg <email@hidden>
- Date: Sun, 24 Aug 2008 12:49:10 +0200
At 14:26 -0700 UTC, on 2008-08-22, Smith, Mike wrote:
[...]
> I have used this script for a few years until I updates from OS X 10.4.8 to
>OS X 10.4.11 and now it is broke. I have tried using attach as the verb
>instead of mount and that works spasmodically or not at all.
>
> I have googled and read the man hdiutil and I still can't get it to work.
>There are no error messages.
You put everything in a atry block that ignores errors ;) If you want to
catch errors, do:
try
-- do stuff
on error m number n
-- do something useful, like
log {n, m}
end
[...]
> --12OCT2005 - mounts thee images as CDs to the desktop
>
> tell application "Finder"
You could just as well have told app "Mail". Never ever tell an application
that doesn't need to be told. You'll only dig yourself into a hole.
(AppleScript is much like Web browsers; tries to be user friendly by guessing
what you mean. Seems nice at first, but if you get used to relying on that,
one day AS won't be able to guess what you meant, and you won't know how to
tell it what you mean.)
As to mounting disk images: I haven't tried under anything beyond Panther
(10.3.9), but at least there I found that this works somewhat confusing in
that mounting *does* work, but not in a visible/useful manner if there is no
mountpoint created first. So I wrote a script that first checks whether the
mountpoint I need exists, if not creates it, and only then mount the image.
(The script is a little more elaborate than you're asking for. It als defines
a UID and GUID, to ensure that the image is mounted. Just ignore those bits.)
--settings
property volume_name : "k3wl"
property image_path : "/path/to/file.sparseimage"
property volume_owner : "a (short) user name"
-- make sure mountpoint exists
repeat
set the_volumes to (every word of (do shell script "ls /Volumes"))
if volume_name is in the_volumes then
exit repeat
else
do shell script "mkdir /Volumes/" & volume_name
end if
end repeat
-- get volume_owner's uid and guid
set volume_owner_uid_gid to (words 2 thru 3 of (do shell script "nireport /
/users name uid gid | grep " & volume_owner))
set {volume_owner_uid, volume_owner_gid} to {item 1 of volume_owner_uid_gid,
item 2 of volume_owner_uid_gid}
-- attach without mounting and grab the assigned device path in order to know
how to mount it
set device_name to (second word of last paragraph of (do shell script
"hdiutil attach -nomount" & " " & image_path))
set device_path to "/dev/" & device_name
-- mount it
do shell script "mount -t hfs -o -u=" & volume_owner_uid & ",-g=" &
volume_owner_gid & ",-m=771" & " " & device_path & " " & "/Volumes/" &
volume_name & "/"
--
Sander Tekelenburg, <http://www.euronet.nl/~tekelenb/>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden