|
Description:
A simple yet effective way to parse the output of
cdrecord -scanbus and cdrecord -checkdrive to
show a list of all devices and what they are
Usage: Text Source
my @list=;
my $cnt=0;
my @drives;
foreach (@list) {
chomp $_;
$_ =~ s/ //g;
$_ =~ s/ //g;
while (length($_) > 5) {
chop $_;
}
print "#$cnt ($_)\n";
$drives[$cnt]=$_;
$cnt++;
}
$cnt=0;
foreach (@drives) {
chomp $_;
my @ident=;
foreach (@ident) {
chomp $_;
if (grep(/seems to be/, $_)) {
if (grep(/CD-RW/, $_)) {
print "#$cnt CDRW DEVICE\n";
} elsif (grep(/CCS Disk/, $_)) {
print "#$cnt Disk DEVICE\n";
} elsif (grep(/CD-ROM/, $_)) {
print "#$cnt CDROM DEVICE\n";
} else {
print "#$cnt OTHER DEVICE\n";
}
}
}
$cnt++;
}
The license for this recipe is available here.
Discussion:
|