LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-19-2009, 10:55 AM   #1
slinx
Member
 
Registered: Apr 2008
Location: Cleveland, Ohio
Distribution: SuSE, CentOS, Fedora, Ubuntu
Posts: 106

Rep: Reputation: 23
Question Detecting media type loaded in CD/DVD writer


Hello,

Is there a way to quickly detect what type of media is loaded in a drive, and whether it is blank or not, besides using mount to see if you can mount the disc?

I found a posting that suggested using dvd+rw-mediainfo, but this tool only works for DVD media.

I have a backup script that requires using CD-Rs. I want the script to be able to check whether a CD-R, CD-RW, or DVD-R is loaded, and to check if it is writable or not, then either proceed if it is a blank CD-R, or return an error if the wrong media is loaded.

Thank you.
 
Old 03-20-2009, 04:23 AM   #2
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Try:

Code:
cdrecord -prcap dev=/dev/cdrom 2>/dev/null | grep 'Current:'
 
Old 03-20-2009, 09:11 AM   #3
slinx
Member
 
Registered: Apr 2008
Location: Cleveland, Ohio
Distribution: SuSE, CentOS, Fedora, Ubuntu
Posts: 106

Original Poster
Rep: Reputation: 23
Thanks, but that only shows me the read and write speeds for the media - doesn't tell me what type it is or if it's blank.
 
Old 03-20-2009, 10:46 AM   #4
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Ok, try this instead:

Code:
cdrecord -media-info dev=/dev/cdrom 2>/dev/null | grep 'disk status:'
cdrecord -media-info dev=/dev/cdrom 2>/dev/null | grep 'Mounted media type'
this gives you the disk status ('empty' or 'complete') and media type, and you can further pipe these to awk to get the second column i.e. | awk '{ print $2 }'

However, the other command did work for me:
Code:
bash-3.1$ cdrecord -prcap dev=/dev/cdrom 2>/dev/null | grep 'Current:'
Current: none
bash-3.1$ cdrecord -prcap dev=/dev/cdrom 2>/dev/null | grep 'Current:'
Current: CD-R
bash-3.1$ cdrecord -prcap dev=/dev/cdrom 2>/dev/null | grep 'Current:'
Current: DVD-R sequential recording
when I put in a CD-R and DVD-R.

Last edited by H_TeXMeX_H; 03-20-2009 at 10:48 AM.
 
Old 03-20-2009, 11:35 AM   #5
slinx
Member
 
Registered: Apr 2008
Location: Cleveland, Ohio
Distribution: SuSE, CentOS, Fedora, Ubuntu
Posts: 106

Original Poster
Rep: Reputation: 23
What version of cdrecord are you using?

I'm using Cdrecord-Clone 2.01a32-dvd (i686-pc-linux-gnu) and it reports "Bad option: -media-info"

Last edited by slinx; 03-20-2009 at 11:41 AM.
 
Old 03-20-2009, 11:51 AM   #6
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
I'm using:

Code:
bash-3.1$ cdrecord --version
Cdrecord-ProDVD-ProBD-Clone 2.01.01a38 (x86_64-unknown-linux-gnu) Copyright (C) 1995-2008 Jörg Schilling
 
Old 03-20-2009, 01:05 PM   #7
slinx
Member
 
Registered: Apr 2008
Location: Cleveland, Ohio
Distribution: SuSE, CentOS, Fedora, Ubuntu
Posts: 106

Original Poster
Rep: Reputation: 23
I just built Cdrecord-Clone 2.01 (i686-pc-linux-gnu) Copyright (C) 1995-2004 Jörg Schilling

-media-info must be in only the x64 version, because it still complains, - Or do you need the Pro version to work? I get a little farther with -atip, but -prcap still doesn't give me the information I need, -prcap only gives me the current read/write speed, and -atip only tells me if it's a DVD - it won't identify a CD-R... but that's a start... thanks for your help.
 
Old 03-20-2009, 02:33 PM   #8
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
I have just tested it on my Slackware 12.1 computer and it works on there too, so it's not x64 specific. If you want, try compiling this exact version or higher:
http://www.slackware.at/data/slackwa....01a38.tar.bz2
I have also tested 2.01.01a58 from the official site:
ftp://ftp.berlios.de/pub/cdrecord/al....01a58.tar.bz2
it also works.
 
Old 03-20-2009, 03:44 PM   #9
slinx
Member
 
Registered: Apr 2008
Location: Cleveland, Ohio
Distribution: SuSE, CentOS, Fedora, Ubuntu
Posts: 106

Original Poster
Rep: Reputation: 23
That's the solution - the latest alpha version of cdrecord does the trick. Now I will just have to convince people we need to upgrade the tool.

Thanks for your help!
 
Old 03-20-2009, 04:39 PM   #10
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
No problem
 
  


Reply

Tags
cd, cdrecord, dvd, dvddevice



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
amarok: Some media could not be loaded itzig Linux - Software 7 10-06-2007 03:32 PM
Burning ISO image (DVD+R, external DVD writer) swan2925 Linux - Software 6 06-02-2005 09:49 AM
Cannot find DVD writer or get CD-writer to spin audio disk dgwebb Linux - Hardware 5 03-28-2005 05:00 PM
K3B not detecting Writer _UnPrEdictAbLe_ Linux - Software 2 01-07-2005 03:33 AM
Detecting write-protection on DVD-RAM media SMes Linux - Software 0 11-24-2004 06:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration