How to Eject a CD From the Command Line

For those with nothing better to do at the command line, the eject command lets you open and close the tray in your CD drive.

Enter eject to eject the tray, and eject -t to close the try.

You may be surprised to see the wealth of options eject supports given its purpose, so enter man eject to read what is possible.

Let’s automate the process. Write a looping script, and watch the tray receive a workout!

function ejectme()
   # Eject
   echo "Now you see me!"
   # Close
   echo "Now you don't"
   eject -t

for ((i = 0; i < 5; i++))

And for those feeling particularly mischievous, SSH into another computer and what watch happens after entering eject. Gives “remote administration” a whole new meaning!


, ,

  1. #1 by anthonyvenable110 on May 19, 2012 - 7:55 PM

    Ok that was a great idea!!!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: