Bash update cdrom status
Johnny Rosenberg
gurus.knugum at gmail.com
Sun Nov 24 12:32:24 UTC 2013
2013/11/24 Colin Law <clanlaw at googlemail.com>
> On 23 November 2013 23:41, Johnny Rosenberg <gurus.knugum at gmail.com>
> wrote:
> >
> > Let's say I have a cd-r/w in my cd burner. It's not empty:
> > # Variables
> > CdRom="/dev/sr0"
> >
> > # Functions
> > HasMedia () {
> > udisks --show-info "${CdRom}" | grep "has media.*1" > /dev/null
> > return $?
> > }
> >
> > IsNotEmpty () {
> > udisks --show-info "${CdRom}" | grep "blank.*0" > /dev/null
> > return $?
> > }
> > # End of code
> >
> > Now:
> > $ if IsNotEmpty; then echo "Not empty"; else echo "Empty"; fi
> > Not empty
> > $
> >
> > So far, so good. Now I erase the disc:
> >
> > umount "${CdRom}"
> > cdrecord blank=fast dev="${CdRom}"
> >
> > When finished:
> > $ if IsNotEmpty; then echo "Not empty"; else echo "Empty"; fi
> > Not empty
> > $
> >
> > So I eject the disc:
> > eject $CdRom
> >
> > Then I insert it again and wait. Meanwhile:
> > $ if HasMedia; then echo "Disc found"; else echo "Disc missing"; fi
> > Disc missing
> > $ if HasMedia; then echo "Disc found"; else echo "Disc missing"; fi
> > Disc missing
> > $ if HasMedia; then echo "Disc found"; else echo "Disc missing"; fi
> > Disc missing
> > $ if HasMedia; then echo "Disc found"; else echo "Disc missing"; fi
> > Disc found
> > $
> >
> > Good, disc found. Is it empty?
> > $ if IsNotEmpty; then echo "Not empty"; else echo "Empty"; fi
> > Empty
> > $
> >
> > Great! But how can I do this without ejecting the disc? Is there some
> ”disc
> > status update” thing to do, to make the cd reader re-read the disc
> somehow?
>
> What does the udisks command in your script show before and after blanking
> it?
>
They showed the same thing before and after blanking. Just to be sure, I'll
test that again right now:
I have an empty CD-R/W inserted right now, so I'm going to burn a small
file to it with Brasero… doing it as I write this right now.
Okay, done.
Now I'll close Brasero and open the gnome terminal.
~$ udisks --show-info "${CdRom}" | grep "blank"
blank: 0
~$
So it's not blank now, which make sense.
Now I will blank it:
~$ cdrecord blank=fast dev="${CdRom}"
wodim: Operation not permitted. Warning: Cannot raise RLIMIT_MEMLOCK limits.
Device type : Removable CD-ROM
Version : 5
Response Format: 2
Capabilities :
Vendor_info : 'Optiarc '
Identification : 'DVD RW AD-5540A '
Revision : '2.61'
Device seems to be: Generic mmc2 DVD-R/DVD-RW.
Using generic SCSI-3/mmc CD-R/CD-RW driver (mmc_cdr).
Driver flags : MMC-3 SWABAUDIO BURNFREE
Supported modes: TAO PACKET SAO SAO/R96R RAW/R96R
Speed set to 706 KB/s
Starting to write CD/DVD at speed 4.0 in real BLANK mode for single session.
Last chance to quit, starting real write in 0 seconds. Operation starts.
~$
And now, checking again:
~$ udisks --show-info "${CdRom}" | grep "blank"
blank: 0
~$
So, still not blank. Ejecting.
~$ eject $CdRom
~$
And putting it back in (I have a laptop so I need to do it manually, using
my bare hands…).
Now, checking again:
~$ udisks --show-info "${CdRom}" | grep "has"
has media: 1 (detected at söndag 2013-11-24 13:29)
~$ udisks --show-info "${CdRom}" | grep "blank"
blank: 1
~$
So, it still seems like I need to reload the disc somehow, either ejecting
and putting it back in, or if there is some fancy command around that I can
use to re-read the disc or update the cd drive status.
Johnny Rosenberg
>
> Colin
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20131124/ae523d79/attachment.html>
More information about the ubuntu-users
mailing list