Re: how to eject a firewire drive natively
Re: how to eject a firewire drive natively
- Subject: Re: how to eject a firewire drive natively
- From: Graff <email@hidden>
- Date: Sun, 11 Apr 2004 00:42:22 -0400
On Apr 10, 2004, at 12:46 PM, Axel Luttgens wrote:
Graff wrote:
[...]
Still, I'd love to know why diskutil works on the command line but
not from AppleScript.
Me too ;-)
Has someone found an explanation? [1]
Axel
[1] As a reminder: "diskutil eject /Volumes/volname" executed on the
command line works without problem. But works only partially when
executed in a "do shell script" command: the disk gets unmounted, but
won't be ejected (and the corresponding /dev entries remain).
To my knowledge no one ever tried to answer it so I'm assuming it has
everyone stumped or that no one really cares to investigate it.
It certainly seems like buggy behavior to me. I see no really good
reason why this command should react so differently when executed from
the command line as opposed to through a "do shell script" command. I
even attempted to duplicate the environment that the "do shell script
command" uses and I still didn't get the same result as through
AppleScript.
Upon further consideration I at least have come up with a workaround,
but not much of an explanation. You can get the script to work by
completely backgrounding the "do shell script" command. Apparently
there's some kind of odd interaction between AppleScript's "do shell
script" environment and the "diskutil" shell tool that causes it to
exhibit buggy behavior. Putting the command in the background seems to
fix the behavior so that the tool completes its task. I consider this
a workaround, not a solution or explanation so be careful with it:
----------
set diskName to "Jedi Academy Disc 1"
-- Jedi Academy Disc 1 is a CD-ROM disk
set posixPath to quoted form of ("/Volumes/" & diskName)
do shell script "diskutil eject " & posixPath & "> /dev/null 2>&1 &"
----------
- Ken
Here was my original post on the matter, so you don't have to dig for
it:
Ok, oddly enough I just tried this and I'm having problems with it. I
used this script:
-----------
set diskName to "Jedi Academy Disc 1"
-- Jedi Academy Disc 1 is a CD-ROM disk
set posixPath to quoted form of ("/Volumes/" & diskName)
do shell script "diskutil eject " & posixPath
-----------
This ends up producing the command:
diskutil eject '/Volumes/Jedi Academy Disc 1'
Which produces this result in AppleScript:
""
The disk gets removed from the desktop and the entry for it in
/Volumes is also removed, however the disk does not get ejected and
the /dev entry for the disk is still there.
When I do the command directly in the shell the disk is removed from
the desktop, from /Volumes, the /dev entry is removed, and the disk
gets ejected from the drive. This is the result from the command:
Disk /Volumes/Jedi Academy Disc 1 ejected
Can anyone shed some light on this? I can't figure out why a shell
command executed from AppleScript would do this. I even ran the
command in a sh shell session to see if there was some sort of
difference there. It ran exactly the same under sh as it did in tcsh.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.