<div dir="ltr">2013/11/24 Colin Law <span dir="ltr"><<a href="mailto:clanlaw@googlemail.com" target="_blank">clanlaw@googlemail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class=""><div class="h5">On 23 November 2013 23:41, Johnny Rosenberg <<a href="mailto:gurus.knugum@gmail.com">gurus.knugum@gmail.com</a>> wrote:<br>
><br>
> Let's say I have a cd-r/w in my cd burner. It's not empty:<br>
> # Variables<br>
> CdRom="/dev/sr0"<br>
><br>
> # Functions<br>
> HasMedia () {<br>
>       udisks --show-info "${CdRom}" | grep "has media.*1" > /dev/null<br>
>       return $?<br>
> }<br>
><br>
> IsNotEmpty () {<br>
>       udisks --show-info "${CdRom}" | grep "blank.*0" > /dev/null<br>
>       return $?<br>
> }<br>
> # End of code<br>
><br>
> Now:<br>
> $ if IsNotEmpty; then echo "Not empty"; else echo "Empty"; fi<br>
> Not empty<br>
> $<br>
><br>
> So far, so good. Now I erase the disc:<br>
><br>
> umount "${CdRom}"<br>
> cdrecord blank=fast dev="${CdRom}"<br>
><br>
> When finished:<br>
> $ if IsNotEmpty; then echo "Not empty"; else echo "Empty"; fi<br>
> Not empty<br>
> $<br>
><br>
> So I eject the disc:<br>
> eject $CdRom<br>
><br>
> Then I insert it again and wait. Meanwhile:<br>
> $ if HasMedia; then echo "Disc found"; else echo "Disc missing"; fi<br>
> Disc missing<br>
> $ if HasMedia; then echo "Disc found"; else echo "Disc missing"; fi<br>
> Disc missing<br>
> $ if HasMedia; then echo "Disc found"; else echo "Disc missing"; fi<br>
> Disc missing<br>
> $ if HasMedia; then echo "Disc found"; else echo "Disc missing"; fi<br>
> Disc found<br>
> $<br>
><br>
> Good, disc found. Is it empty?<br>
> $ if IsNotEmpty; then echo "Not empty"; else echo "Empty"; fi<br>
> Empty<br>
> $<br>
><br>
> Great! But how can I do this without ejecting the disc? Is there some ”disc<br>
> status update” thing to do, to make the cd reader re-read the disc somehow?<br>
<br>
</div></div>What does the udisks command in your script show before and after blanking it?<br></blockquote><div><br></div><div>They showed the same thing before and after blanking. Just to be sure, I'll test that again right now:</div>
<div>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.</div><div>Okay, done.</div><div>Now I'll close Brasero and open the gnome terminal.</div>
<div>~$ udisks --show-info "${CdRom}" | grep "blank"<br>    blank:                     0<br>~$ <br></div><div><br></div><div>So it's not blank now, which make sense.</div><div>Now I will blank it:</div>
<div>~$ cdrecord blank=fast dev="${CdRom}"<br>wodim: Operation not permitted. Warning: Cannot raise RLIMIT_MEMLOCK limits.<br>Device type    : Removable CD-ROM<br>Version        : 5<br>Response Format: 2<br>Capabilities   : <br>
Vendor_info    : 'Optiarc '<br>Identification : 'DVD RW AD-5540A '<br>Revision       : '2.61'<br>Device seems to be: Generic mmc2 DVD-R/DVD-RW.<br>Using generic SCSI-3/mmc   CD-R/CD-RW driver (mmc_cdr).<br>
Driver flags   : MMC-3 SWABAUDIO BURNFREE <br>Supported modes: TAO PACKET SAO SAO/R96R RAW/R96R<br>Speed set to 706 KB/s<br>Starting to write CD/DVD at speed   4.0 in real BLANK mode for single session.<br>Last chance to quit, starting real write in    0 seconds. Operation starts.<br>
~$</div><div><br></div><div>And now, checking again:</div><div>~$ udisks --show-info "${CdRom}" | grep "blank"<br>    blank:                     0<br>~$ </div><div>So, still not blank. Ejecting.</div><div>
<br></div><div>~$ eject $CdRom <br>~$</div><div><br></div><div>And putting it back in (I have a laptop so I need to do it manually, using my bare hands…).</div><div>Now, checking again:</div><div>~$ udisks --show-info "${CdRom}" | grep "has"<br>
  has media:                   1 (detected at söndag 2013-11-24 13:29)<br>~$ udisks --show-info "${CdRom}" | grep "blank"<br>    blank:                     1<br>~$ </div><div><br></div><div>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.</div>
<div><br></div><div><br></div><div>Johnny Rosenberg</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=""><font color="#888888"><br>
Colin<br>
<br>
--<br>
ubuntu-users mailing list<br>
<a href="mailto:ubuntu-users@lists.ubuntu.com">ubuntu-users@lists.ubuntu.com</a><br>
Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/ubuntu-users" target="_blank">https://lists.ubuntu.com/mailman/listinfo/ubuntu-users</a><br>
</font></span></blockquote><br></div>