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?
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:
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:
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:
Note that
/dev/cdrom1
is the logic name of my CDROM device. You need to executesudo lshw -C disk
command to see your CDROM's logic name.