Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How can I list all the installed optical drivers with udev or any other core-based tool (perl is also very good) ?

P.S.: I know about the wodim --devices command, but it's an undesirable dependence.

share|improve this question

migrated from serverfault.com Feb 25 '13 at 7:49

This question came from our site for professional system and network administrators.

add comment

1 Answer 1

If you like Perl, then this example code found in CPAN could do the trick. It also have low dependencies. The library you need is Device-Cdio.

use strict;

BEGIN {
    chdir 'example' if -d 'example';
    use lib '../lib';
    eval "use blib";  # if we fail keep going - maybe we have installed Cdio
}

use Device::Cdio;
use Device::Cdio::Device;
use Device::Cdio::Track;
use vars qw($0 $program $pause %opts);

sub print_drive_class($$$) {
    my ($msg, $bitmask, $any) = @_;
    my @cd_drives = Device::Cdio::get_devices_with_cap($bitmask, $any);
    print "$msg...\n";
    foreach my $drive (@cd_drives) {
    print "Drive $drive\n";
    }
    print "-----\n";
}
my @cd_drives = Device::Cdio::get_devices($perlcdio::DRIVER_DEVICE);
foreach my $drive (@cd_drives) {
    print "Drive $drive\n";
}
print "-----\n";
print_drive_class("All CD-ROM drives (again)", $perlcdio::FS_MATCH_ALL, 0);
share|improve this answer
    
dmesg | awk '/CD-ROM/ && /Attached/{print "/dev/"$NF}' –  Rahul Patil Feb 25 '13 at 9:22
    
@RahulPatil is this supposed to work ? Because it doesn't in my system. –  drcelus Feb 25 '13 at 10:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.