LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 03-22-2007, 06:31 AM   #1
rain_jm
LQ Newbie
 
Registered: Mar 2007
Location: Canberra, Australia
Posts: 6

Rep: Reputation: 0
Question How to detect the type of a CD in the CD-ROM?


How to detect the CD in the CD-ROM is a:
CD?
CD-R?
CD-RW?
DVD?
DVD-R?
DVD-RW?
or something else?

Thanks.
 
Old 03-22-2007, 08:17 AM   #2
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
Not sure about specifics from one software to the next, but the drive itself tends to know what's inside itself, to a point.
type 'hdparm' for the help page. There you will see hdparm options which can be applied to the drive. One of them, I think it's a -I will return all info that the drive has about itself in general, including the type of disk to the best of its knowledge in some drives.
Perhaps using grep or cat on the results of hdparm -I /dev/hd? to isolate the disk type is what you are looking for?
There may be another way, but this came to mind first.
 
Old 03-22-2007, 06:04 PM   #3
rain_jm
LQ Newbie
 
Registered: Mar 2007
Location: Canberra, Australia
Posts: 6

Original Poster
Rep: Reputation: 0
Thank you GrapefruiTgirl, i typed this command, but there is no such command.
By the way, i'm using Fedora Core 3 at this moment.
 
Old 03-22-2007, 06:06 PM   #4
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
Oops, I should have mentioned, if your system does not have hdparm, you can get it from Sourceforge.net, or just google it
Sorry for the inconvenience.
 
Old 03-22-2007, 07:55 PM   #5
rain_jm
LQ Newbie
 
Registered: Mar 2007
Location: Canberra, Australia
Posts: 6

Original Poster
Rep: Reputation: 0
That's Ok.

Actually, I'm writing a program that will only write data on a Blank CD-R, unless there is a way to make the CR-RW to be CD-R after writing.

That's why i need to detect the type of the CD.
 
Old 03-22-2007, 08:04 PM   #6
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
Once a CDRW is finalised, it technically becomes a CD-R. However, as I understand it, they can still be ERASED, and made into a CDRW again, until their maximum usage has been reached, which is around 1000 writes.
 
Old 03-22-2007, 09:15 PM   #7
rain_jm
LQ Newbie
 
Registered: Mar 2007
Location: Canberra, Australia
Posts: 6

Original Poster
Rep: Reputation: 0
Exactly, but what i need to do is to ensure the CD is a CD-R, so the data i wrote on that CD is unchangeable for some security reason.

somebody suggested:

media_type="unknown-media"
infotext=$(cdrecord dev=$scsi_adr -atip 2>&1)
if echo "$infotext" | \
grep 'book type:.*DVD+RW' >/dev/null 2>&1
then
media_type="DVD+RW"
elif echo "$infotext" | \
grep 'book type:.*DVD-RW' >/dev/null 2>&1
then
media_type="DVD-RW"
elif echo "$infotext" | \
grep 'book type:.*DVD+R' >/dev/null 2>&1
then
media_type="DVD+R"
elif echo "$infotext" | \
grep 'book type:.*DVD-R' >/dev/null 2>&1
then
media_type="DVD-R"
elif echo "$infotext" | \
grep '^ Is erasable' >/dev/null 2>&1
then
media_type="CD-RW"
elif echo "$infotext" | \
grep '^ Is not erasable' >/dev/null 2>&1
then
media_type="CD-R"
fi
echo "Detected media type : $media_type"

But i'm not familar with shell script, so i haven't found out if this work.
 
  


Reply



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
Debian installer cannot detect my cd-rom kazu182 Debian 5 02-26-2007 03:46 PM
How can I detect CPU/OS type within C++ ? fcdev Programming 3 07-25-2006 05:50 PM
Mandrake does not detect CD ROM carlosinfl Mandriva 0 09-28-2004 01:02 PM
Redhat won't detect my Cd-Rom to install coolgy768 Linux - Newbie 7 10-24-2003 01:04 AM
CD-ROM drives don't auto-detect (sometimes) justin19fl General 2 07-29-2001 09:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 07:25 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