LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux > 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

Tags used in this thread
Popular LQ Tags , , ,

Reply
 
Thread Tools
Old 03-19-2009, 11:55 AM   #1
slinx
Member
 
Registered: Apr 2008
Location: Cleveland, Ohio
Posts: 40
Thanked: 0
Question Detecting media type loaded in CD/DVD writer


[Log in to get rid of this advertisement]
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.
slinx is offline  
Tag This Post , , ,
Reply With Quote
Old 03-20-2009, 05:23 AM   #2
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 6,739
Blog Entries: 2
Thanked: 216
Try:

Code:
cdrecord -prcap dev=/dev/cdrom 2>/dev/null | grep 'Current:'
H_TeXMeX_H is offline     Reply With Quote
Old 03-20-2009, 10:11 AM   #3
slinx
Member
 
Registered: Apr 2008
Location: Cleveland, Ohio
Posts: 40
Thanked: 0

Original Poster
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.
slinx is offline     Reply With Quote
Old 03-20-2009, 11:46 AM   #4
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 6,739
Blog Entries: 2
Thanked: 216
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 11:48 AM..
H_TeXMeX_H is offline     Reply With Quote
Old 03-20-2009, 12:35 PM   #5
slinx
Member
 
Registered: Apr 2008
Location: Cleveland, Ohio
Posts: 40
Thanked: 0

Original Poster
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 12:41 PM..
slinx is offline     Reply With Quote
Old 03-20-2009, 12:51 PM   #6
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 6,739
Blog Entries: 2
Thanked: 216
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
H_TeXMeX_H is offline     Reply With Quote
Old 03-20-2009, 02:05 PM   #7
slinx
Member
 
Registered: Apr 2008
Location: Cleveland, Ohio
Posts: 40
Thanked: 0

Original Poster
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.
slinx is offline     Reply With Quote
Old 03-20-2009, 03:33 PM   #8
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 6,739
Blog Entries: 2
Thanked: 216
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.
H_TeXMeX_H is offline     Reply With Quote
Thanked by:
Old 03-20-2009, 04:44 PM   #9
slinx
Member
 
Registered: Apr 2008
Location: Cleveland, Ohio
Posts: 40
Thanked: 0

Original Poster
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!
slinx is offline     Reply With Quote
Old 03-20-2009, 05:39 PM   #10
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 6,739
Blog Entries: 2
Thanked: 216
No problem
H_TeXMeX_H is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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 04:32 PM
Burning ISO image (DVD+R, external DVD writer) swan2925 Linux - Software 6 06-02-2005 10:49 AM
Cannot find DVD writer or get CD-writer to spin audio disk dgwebb Linux - Hardware 5 03-28-2005 06:00 PM
K3B not detecting Writer _UnPrEdictAbLe_ Linux - Software 2 01-07-2005 04:33 AM
Detecting write-protection on DVD-RAM media SMes Linux - Software 0 11-24-2004 07:43 AM


All times are GMT -5. The time now is 08:54 PM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration