10

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?

2
  • 2
    Ubuntu and Parenting advice all in one question got to vote that up
    – Allan
    Nov 27, 2010 at 16:49
  • @Jorge. I have separated the answer.
    – Bakhtiyor
    Nov 28, 2010 at 10:36

2 Answers 2

10

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
0
2

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .