Titling this one was a little harder than most somehow.   I guess part of it is that there are so many ways to express this.

Today I needed to use a Mac whose monitor got … appropriated… by my family for other purposes. I just needed to use a piece of software there that is only needed once in a … well, almost never.

To get to the point, Apple’s Remote Desktop product is nice, and offers good control, but doesn’t have anything I could find that would eject the tray.  If a disk had been already in it, it could have been used to eject that of course.

Anyway,  the first solution I found is a command-line tool in the Mac:  drutil.  Just connect to the “headless” Mac with SSH in a terminal (there are plenty of how-to’s available via Google) then type this:

drutil -drive 1 tray open

The tray popped out and my problem is solved.

I tried putting this into an AppleScript application so that I could put it on the dock. Then it would only be a click away.  A quick test showed that this does nothing if a disk is actually mounted from the drive.  No error message is generated. It also became clear that this command is literal, it will only open the tray.   To close the tray, I had to issue the reverse command:

drutil -drive 1 tray close

(I suppose that’ll require another AppleScript application.)

If you’d like one, just type the following line into a blank document in the AppleScript Editor program.  The quotes are necessary to send the whole thing together,  othewise AppleScript will try to interpret each word in the line.

do shell script “drutil -drive 1 tray open”

I did search around to see if there was an open/close command.  After all, the eject button on the keyboard gets it right. (when one is connected) and so does the drive’s button (when its not covered up by the Mac case.)  But I didn’t turn up anything in the few minutes available.


Tags: , ,