[clug] Is a CD in a drive..

Owen rcook at pcug.org.au
Wed Mar 25 07:43:50 GMT 2009

> Hi all,
> Anyone know a magic cat  /proc/blue/blah/blonk incantation that I can
> use in a (sh) script to tell if a CDROM is in a drive?
> Note, _in_ the drive not necessarily mounted. All I have so far is:
>    $ scsi_ready /dev/scd0
> Seems to work but I don't know if it is the "right" way to do such
> things and there seems to be no docco on scsi_ready.
> suggestions along the lines of:
>    $ dd if=/dev/null of=/dev/scd0 bs=512 count=1
> will be ignored.. :)

Well I wondered about isoinfo. here is the output from the dvd drive
without a cd in it

owen at owen-desktop:~$ isoinfo -d -i /dev/sr0
Errno: 5 (Input/output error), test unit ready scsi sendcmd: no error
CDB:  00 00 00 00 00 00
status: 0x2 (CHECK CONDITION)
Sense Bytes: 70 00 02 00 00 00 00 0A 00 00 00 00 3A 01 00 00
Sense Key: 0x2 Not Ready, Segment 0
Sense Code: 0x3A Qual 0x01 (medium not present - tray closed) Fru 0x0
Sense flags: Blk 0 (not valid)
cmd finished after 0.000s timeout 20s
isoinfo: No such file or directory. Unable to open /dev/sr0

and here is the output with a CD (containing just images) in the
drive, but unmounted

owen at owen-desktop:~$ isoinfo -d -i /dev/sr0
CD-ROM is in ISO 9660 format
System id:
Volume id: MY_DISC
Volume set id:
Publisher id:
Data preparer id:
Application id: NERO BURNING ROM
Copyright File id:
Abstract File id:
Bibliographic File id:
Volume set size is: 1
Volume set sequence number is: 1
Logical block size is: 2048
Volume size is: 171549
Joliet with UCS level 3 found
NO Rock Ridge present
owen at owen-desktop:~$

Maybe you could make use of that?


More information about the linux mailing list