[Tutor] Reading the CDROM in Linux

Terry Carroll carroll at tjc.com
Sat Nov 6 01:59:19 CET 2010


Alan Gauld wrote:

> I don't use Ubuntu so don;t know the standard anmswer
> there but it will depend on where the CD is mounterd.
>
> I usually mount cdroms on /dev/cdrom

That's what I figured; I now realize I didn't say so in my email, but it's 
mounted at /dev/sr0, which is where I came up with that mount point.


  tjrc at vraspberry:~$ df
   . . .

  /dev/sr0               614350    614350         0 100% /media/MP_04_074


MP_04_074 is the volume name.

But in python:

>>> import os
>>> for (r, d, f) in os.walk("/dev/sr0"): print r, d, f
...
>>> for (r, d, f) in os.walk("/dev/sr0/"): print r, d, f
...
>>> for (r, d, f) in os.walk("/dev/cdrom/"): print r, d, f
...
>>> for (r, d, f) in os.walk("/dev/cdrom"): print r, d, f
...
>>> for (r, d, f) in os.walk("/dev/cdrom0"): print r, d, f
...
>>> for (r, d, f) in os.walk("/dev/cdrom0/"): print r, d, f
...


None of those work; but:


>>> for (r, d, f) in os.walk("/media/MP_04_074"): print r, d, f
...
/media/MP_04_074 ['directory1'] []
(etc.)


What I can't figure out is how to do this if my program does not know the 
volume name.  I won't know the colume name in advance, and in fact, I'll 
be processing one CDROM, replacing it and processing another, etc.


More information about the Tutor mailing list