Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Open/Close External CD Drive

Open/Close External CD Drive
Thread Tools
Mac Elite
Join Date: Nov 2003
Location: Rockville, MD
Status: Offline
Reply With Quote
Feb 8, 2005, 09:31 PM
 
I know how to make my external CD burner open its tray:
Code:
do shell script "drutil tray eject -drive external"
and I know how to make it close again:
Code:
do shell script "drutil tray close -drive external"
What I can't figure out is how to make it close if currently open and/or open if curently closed; i.e., check its open/closed status. After determing the status, a simple if/then statement based on that info hould do the trick, right?
     
Mac Elite
Join Date: Sep 2000
Location: in front of the keyboard
Status: Offline
Reply With Quote
Feb 8, 2005, 09:58 PM
 
Why do you even need those conditionals?

I mean, what harm is there in telling an already ejected tray to eject? Nothing happens.

I just tested it and there's no harm in issuing drutil eject over and over. Likewise with drutil tray close.
signatures are a waste of bandwidth
especially ones with political tripe in them.
     
Mac Elite
Join Date: Nov 2003
Location: Rockville, MD
Status: Offline
Reply With Quote
Feb 8, 2005, 11:11 PM
 
Originally posted by Kristoff:
Why do you even need those conditionals?

I mean, what harm is there in telling an already ejected tray to eject? Nothing happens.

I just tested it and there's no harm in issuing drutil eject over and over. Likewise with drutil tray close.
No, it does no harm. But I still would rather not issue a frivolous command; it's bad practice. Besides, when the drive is open, I want it to close, and when it's closed, I'd like it to open. My plan is to tie the AppleScript to a key on my Macally keyboard.
     
Professional Poster
Join Date: Sep 1999
Location: Ottawa, ON, Canada
Status: Offline
Reply With Quote
Feb 9, 2005, 12:36 PM
 
Make an invisible file in your user ~/Library/Preferences folder whenever you open the drive tray.

Then in your script, check for the presence of the file.

Pseudo-code:
Code:
if exists file ~/Library/Prefereces/.cdstatusopen { close drivetray delete file .cdstatusopen } else { open drivetray create file .cdstatusopen }
Even if it gets out of sync (i.e. you use the button on the drive), just press your macro key again and it will resync itself.
     
Mac Elite
Join Date: Sep 2000
Location: in front of the keyboard
Status: Offline
Reply With Quote
Feb 9, 2005, 02:54 PM
 
Does the Macally keyboard not have an eject key?

Anyway, you might lauch drutil poll, then watch the messages as you open and close the drive. It will provide some insight.
signatures are a waste of bandwidth
especially ones with political tripe in them.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:08 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2