0 Replies - 1051 Views - Last Post: 08 November 2007 - 08:04 AM

#1 no2pencil  Icon User is online

  • Professor Snuggly Pants
  • member icon

Reputation: 6544
  • View blog
  • Posts: 30,650
  • Joined: 10-May 07

Detect, then eject the cdrom

Posted 08 November 2007 - 08:04 AM

Description: Use the Linux shell to try to detect, then eject the cdrom.
#!/bin/sh
#
# This is just a script for fun, it'll check for the cd-rom in a very
# non-efficient way, & issue the eject command on the results.
# Written by -#2pencil- for Dream In Code 11/08/2007
#

# 1st, test for the command...
which eject; test_results = $?;

if [ ${test_results} -eq 1 ]; then
  echo "The eject command does not exist on this machine"
else
  # take a best guess at the systems cdrom drive
  cd_drive = $(dmesg | grep -i CD-ROM | cut -d: -f1 | grep hd)
  eject ${cd_drive}
  # maybe they use scsi instead of ide?
  scsi_drive = $(dmesg | grep -i CD-ROM | cut -d: -f1 | grep sd)
  eject ${scsi_drive}
fi


Is This A Good Question/Topic? 0
  • +

Page 1 of 1