Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have copied this bunch of code from one funny video clip about How does a programmer swing his baby. The code is following:

#!/bin/bash

while [ l=l ]
do
   #eject cdrom
   eject    
   #pull cdrom track back in
   eject -t
done

But it doesn't work for me, when I run it with the command sh baby_rocker.sh it performs the code and outputs the following message eject: unable to find or open device for: "cdrom" even though I have CD-ROM device on my computer.

How can I make it to work?

share|improve this question
2  
Ubuntu and Parenting advice all in one question got to vote that up –  Allan Nov 27 '10 at 16:49
    
@Allan. Thanks for evaluation of my work. –  Bakhtiyor Nov 27 '10 at 16:55
    
@Jorge. I have separated the answer. –  Bakhtiyor Nov 28 '10 at 10:36
add comment

2 Answers 2

up vote 8 down vote accepted

You need to find your cdrom device name (which per the error is not /dev/cdrom). To find out the cdrom device name from the terminal execute:

sudo lshw -C disk

It should a device starting with "*-cdrom", the device name is listed at the "logical name:" field. Then you need to append the device name to the eject commands on your script, eg:

eject /dev/cdrom1
share|improve this answer
    
Thanks a lot. It was /dev/cdrom1 –  Bakhtiyor Nov 27 '10 at 16:47
add comment

Thanks to the answer of João Pinto, I changed the code and now it works. So, if you decide to swing your baby with CDROM you can change the code as below and enjoy its functionality:

#!/bin/bash

while [ l=l ]
do
   #eject cdrom
   eject /dev/cdrom1
   #pull cdrom track back in
   eject -t /dev/cdrom1
done

Note that /dev/cdrom1 is the logic name of my CDROM device. You need to execute sudo lshw -C disk command to see your CDROM's logic name.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.