CDROM question

bscott at ntisys.com bscott at ntisys.com
Mon Aug 16 19:51:02 EDT 2004


On Mon, 9 Aug 2004, at 3:54pm, colet at code-energy.com wrote:
> A) If a given cdrom drive is open or closed?

  I think this will be drive, and maybe bus, dependent.  Some drives don't
even have a tray, come to think of it.  I've got a slot-load, SCSI bus,
CD/DVD reader on my PC here at home.

> B) If there is a disc in the drive?

  Well, something like this might work:

	if dd if=/dev/cdrom of=/dev/null bs=1 count=1 ; then
		# something readable is there
	else
		# could not read disc
	fi

The 'dd' command will fail with a "No medium found" error if no disc is 
loaded.

  Of course, there are other reasons you might not be able to read the
device besides no being loaded.  Permissions; blank CD-R/CD-RW; non-data
disc; etc.

> If the answer is that I have to try mounting the CD, etc, etc, it's more
> work than it's worth.  This isn't a big deal, I was mostly just curious.

  Okay, well, now I'm curious: What's your application?

-- 
Ben Scott <bscott at ntisys.com>
| The opinions expressed in this message are those of the author and do  |
| not represent the views or policy of any other person or organization. |
| All information is provided without warranty of any kind.              |




More information about the gnhlug-discuss mailing list