Re: Catching Eject Errors
Re: Catching Eject Errors
- Subject: Re: Catching Eject Errors
- From: Jason Kacmarski <email@hidden>
- Date: Sat, 29 May 2004 14:22:25 -0700
Thanks Ken. Here's what I ended up using:
tell application "iTunes"
set mySource to some source whose name contains "iPod"
update mySource
set ipodName to name of mySource
end tell
set myPodPath to quoted form of ("/Volumes/" & ipodName)
repeat while ipodName is in (list disks)
do shell script ("diskutil eject " & myPodPath & "> /dev/null 2>&1 &")
do shell script "sleep 5"
end repeat
On Saturday, May 29, 2004, at 12:49PM, Graff <email@hidden> wrote:
>
In this case I believe you are better off using the "do shell script"
>
command to eject from the shell. If you use the diskutil tool in the
>
shell it will simply fail silently if the disk is in use. So you could
>
attempt to eject, check to see if the volume was unmounted, and then
>
repeat every so often until it is ejected:
>
----
>
tell application "iTunes"
>
set mySource to some source whose name contains "iPod"
>
update mySource
>
set ipodName to name of mySource
>
end tell
>
>
set podPath to quoted form of ("/Volumes/" & ipodName)
>
set isUnmounted to false
>
repeat while not isUnmounted
>
do shell script "diskutil eject " & podPath & "> /dev/null 2>&1 &"
>
delay 5
>
if (ipodName is in (list disks)) then
>
delay 25
>
else
>
set isUnmounted to true
>
end if
>
end repeat
>
----
>
>
I believe that this should work just fine. Give it a try.
>
>
- Ken
>
>
On May 29, 2004, at 1:05 PM, Jason Kacmarski wrote:
>
>
> I'm trying to write a script that will update and then eject my iPod.
>
> I'm running into a problem because the script isn't waiting until
>
> after the update is complete to eject the iPod, which results in a
>
> "disk in use" error. I'm trying to catch the error with a try
>
> statement, but it's not working for some reason. Here's the script
>
> I'm using:
>
>
>
> tell application "iTunes"
>
> set mySource to some source whose name contains "iPod"
>
> update mySource
>
> set ipodName to name of mySource
>
> end tell
>
> tell application "Finder"
>
> try
>
> eject ipodName
>
> on error theErr number errNum
>
> log theErr & " - " & errNum
>
> end try
>
> end tell
>
>
>
> The Finder pops up an error dialog every time and doesn't pass the
>
> error back to the script. Any ideas on how to either get this error
>
> suppressed and passed back to the script so that I can use a delay
>
> loop or check whether a disk is in use before ejecting it? Any help
>
> would be much appreciated.
>
_______________________________________________
>
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.
_______________________________________________
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.