They both work on my machine in two different configurations: one writer drive (internal DVD-ROM/CD-R (basic, non-Super drive)) and two writer drives (the same internal plus an external, USB DVD-RW). But there are some potential bugs.
The main flaw is the assumption that the letter ‘R’ will occur in the drutil list output only if the drive is a recorder. While this is probably always the case for “writer” drives (e.g. CD-R or DVD-R or DVD+R, etc. in the product description), it may also be the case for read-only drives (CD-ROM or plain DVD drives) if there is an ‘R’ in any of the vendor name (e.g. PIONEER), the product description (e.g. “CD-ROM”, or the model number happens to have ‘R’), the revision (similar risk to description), the bus type (e.g. FIREWIRE?, seems more likely to be FireWire though), or the SupportLevel description (unlikely; only a handful of values seem to be produced, none have ‘R’).
To fix this assumption, I might instead egrep for an extended regexp like “<(CD-R|DVD[±]R|BD[±]R)(W>|>)” (the BD part is a guess on my part for how BluRay devices might be reported). That way, you are checking for a word like CD-R or DVD+R, which, while still technically possible, is less likely to occur in any of those other places (mostly because a DVD-ROM with a name that included a word like DVD+R would be confusing to people).
Then again, this is drutil. The dr is for Disc Recording. Maybe read-only drives will never show up in any of the output. Though there are drutil commands that could also work do on read-only drives (eject, tray, discinfo, etc.).
The original " ; echo test ; exit 0" should not hurt. You can remove the " ; echo test", but you might want to leave the " ; exit 0".
The “test” bit was probably there for the author’s testing of the AppleScript code (splitting into paragraphs, checking for ‘R’). It serves as an injected result that we know never contains ‘R’, so if it ever shows up in the final result (dialogs in this case), the filtering mechanism is flawed.
Technically, with the echo in there, the exit is nearly 100% superfluous. But without the echo, it would serve to prevent do shell script from throwing an AppleScript error in any situation where drutil list does not produce any output (or every line of the output contains “SupportLevel”).
Model: iBook G4 933
Browser: Safari 4.0.3 (4531.9)
Operating System: Mac OS X (10.4)