How to detect whethere the CD is R or RW

Hi all,

I need to write a script to write data into cd.
Am using cdrecord command.
i need to implement the following

if ( CD-RW) ( ?? How to find this )
cdrecord blank option
else
cdrecord with out blank option

Now can you please help me to form this statement correctly ?
Basically i need the if "condition "
if ( ????)

Thanks in advance
JS

My OS is red hat linux 8.0

Something like:

#Add any needed device specifications to the line below; by default, it'll use /dev/cdrom.
cdrecord -atip | grep -F 'Is erasable'
if [ $? -eq 0 ]; then
    #cdrecord blank option goes here
else
    #cdrecord CD-R option goes here
fi