View Full Version : can apple script open the cd tray?
bennetsaysargh
Mar 15, 2004, 06:40 PM
if it can, how would you put that into applescript?
thanks :)
sageenos
Mar 15, 2004, 07:02 PM
if it can, how would you put that into applescript?
thanks :)
I just tried it myself, but I can only get it to work for a specific CD in the tray
tell application "Finder"
eject "CDName"
end tell
I'm not sure how to eject any CD or to just cause the tray to open
BrandonRP0123
Mar 15, 2004, 07:15 PM
if it can, how would you put that into applescript?
thanks :)
Not sure how to do it with Apple Script to ``eject all''
You can do it with a unix shell script, however.
You'll need to figure out what disk # your CD/DVD unit is.
Then you could create a script via your favorite unix shell that has in it something like (for my powerbook):
disktool -e disk1 (or you could just execute this yourself by typing it in on the terminal command line)
This method will work when the eject menu and/or key combinations fail as well.
bennetsaysargh
Mar 15, 2004, 07:16 PM
Not sure how to do it with Apple Script to ``eject all''
You can do it with a unix shell script, however.
You'll need to figure out what disk # your CD/DVD unit is.
Then you could create a script via your favorite unix shell that has in it something like (for my powerbook):
disktool -e disk1 (or you could just execute this yourself by typing it in on the terminal command line)
This method will work when the eject menu and/or key combinations fail as well.
how do i find out what disk # my cd/dvd drive is?
bousozoku
Mar 15, 2004, 08:03 PM
Well, if you can do it with the Terminal, you can do it using AppleScript using the Terminal. ;)
tell application "Terminal"
activate
do script "disktool -e disk1"
quit
end tell
Of course, if you keep the Terminal application open, remove the line with "quit" in it.
bousozoku
Mar 16, 2004, 12:55 AM
That works fine as long as something is in the drive. It reports the following:
disk2s1s2 device will attempt to be ejected ...
***Notifications Complete for type 1
***Responding yes to unmount - disk2s1s2
***Disk Unmounted('disk2s1s2')
***Disk Unmounted('disk2')
***Notifications Complete for type 4
***Responding yes to eject - disk2
***Responding yes to eject - disk2s1
***Responding yes to eject - disk2s1s1
***Responding yes to eject - disk2s1s2
***Disk Ejected('disk2')
***Disk Ejected('disk2s1s2')
OutThere
Mar 16, 2004, 12:54 PM
If you don't want to have the terminal come up to do the script then you can do this...
do shell script "disktool -e disk1"
Or you can get really hard-core applescripter and use the "disktool" terminal command to get the list of disks, then tell you what disks there are, and allow you to select from a list the disk you want, and have it ejected, but you might have to spend some time reading the Applescript Studio docs, I don't have time to help you with that right now. Cheers!
tjwett
Mar 16, 2004, 04:12 PM
in Terminal this command is probably the easiest:
drutil tray eject
that's it. of course you could easily have AppleScript tell the Terminal to run this as you normally would.
bennetsaysargh
Mar 16, 2004, 06:14 PM
hey, thanks everyone :)
do shell script "drutil tray eject"
do shell script "drutil tray close"
that's what i am using. is there any way you can make applescript wait a few seconds? i ask this because if you ask it to repeat, it starts closing, but opens back up.
thanks again :)
bousozoku
Mar 16, 2004, 07:42 PM
hey, thanks everyone :)
do shell script "drutil tray eject"
do shell script "drutil tray close"
that's what i am using. is there any way you can make applescript wait a few seconds? i ask this because if you ask it to repeat, it starts closing, but opens back up.
thanks again :)
Of course there is. :D
bennetsaysargh
Mar 16, 2004, 08:02 PM
Of course there is. :D
do you know how? :p
edit-also, does anyone know if you can make something force quit in applescript?
bousozoku
Mar 16, 2004, 09:32 PM
do you know how? :p
edit-also, does anyone know if you can make something force quit in applescript?
I'm going to have to get you a link to the information or buy you a book. :p
delay 10
to delay for 10 seconds
You can use the kill shell script command if you know information about the job you want to force quit.
bennetsaysargh
Mar 17, 2004, 02:11 PM
thanks bousozoku. i really appreciate the help :)
yippy
Mar 17, 2004, 04:13 PM
hey, i want to do the same thing but when i put
do shell script "drutil tray eject"
into applescript and hit run i get an error, it says
sh: drutil: command not found
any help? i am running 10.2.8 if that matters on applescript beta 2.0 and the tcsh shell or whatever it is called in terminal
thanks
Sweetfeld28
Mar 17, 2004, 04:58 PM
hey, i want to do the same thing but when i put
do shell script "drutil tray eject"
into applescript and hit run i get an error, it says
sh: drutil: command not found
any help? i am running 10.2.8 if that matters on applescript beta 2.0 and the tcsh shell or whatever it is called in terminal
thanks
If you don't mind me asking what mac are you using? If you are using an old world mac (ADB-- keyboard and mouse) then i think that by pressing the F12 key it opens the cd tray, the master drive that is. but, i'm sure that you knew this. :D
tjwett
Mar 17, 2004, 05:48 PM
hey, i want to do the same thing but when i put
do shell script "drutil tray eject"
into applescript and hit run i get an error, it says
sh: drutil: command not found
any help? i am running 10.2.8 if that matters on applescript beta 2.0 and the tcsh shell or whatever it is called in terminal
thanks
take a look at the manual page for drutil. i don't think it is included in OS 10.2.x perhaps you can download it somewhere though. i should have said that earlier, sorry. this works in Panther only, unless you install it yourself in 10.2.x
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.