ASPN ActiveState Programmer Network  
ActiveState, a division of Sophos
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups
Submit Recipe
My Recipes

All Recipes
All Cookbooks


View by Category

Title: CDRW Detection under Linux
Submitter: Mark Parker (other recipes)
Last Updated: 2002/09/04
Version no: 1.0
Category: Miscellaneous

 

Not Rated yet


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=`cdrecord -scanbus | grep -v \"\*\" | grep \"\,\"`;

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=`cdrecord -checkdrive dev=$drives[$cnt] 2>/dev/null`;
	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:



Add comment

No comments.



Highest rated recipes:

1. Breaking down a URI into ...

2. Extracting HTML URL Links

3. Removing dangerous ...

4. Matching Royal Mail ...

5. Finding Palindromes

6. Finding URLs in text -- ...

7. Extract the Korean ...

8. Validate Domain Names

9. Validating email ...

10. Remove any HTML




Privacy Policy | Email Opt-out | Feedback | Syndication
© 2006 ActiveState Software Inc. All rights reserved.