diff --git a/wipe.pl b/wipe.pl index bfeae01..6166f97 100755 --- a/wipe.pl +++ b/wipe.pl @@ -48,7 +48,7 @@ sub uniq { # To get the list of devices we will be cleaning sub getdisks { - my $devices = `find /dev/sd*`; + my $devices = `find /dev/sd*[a-z]`; my %listhash = (); foreach(split("\n",$devices)) { my $devicepath = $_; @@ -56,7 +56,7 @@ sub getdisks { my $model = `udevadm info --query=all --name=$_ | grep ID_MODEL | sed -e 's/^.*=//'`; chomp( $serial ); chomp( $model ); - if ( $serial ) { + if ( $serial && $model ) { print $devicepath."\t".$serial."\n"; $listhash{$_}{"path"} = $devicepath; $listhash{$_}{"serial"} = $serial; @@ -118,7 +118,7 @@ sub smartcheck { $disks->{$diskid}{"smart"}{$smartdata[0]}{"raw_value"} = $smartdata[9]; } close( $smartcommand ); - for my $smartentry (keys %{$disks->{$diskid}{"smart"}}) { # I want to have this sort before executing the for loop + for my $smartentry (sort {$a cmp $b} keys %{$disks->{$diskid}{"smart"}}) { if ($disks->{$diskid}{"smart"}{$smartentry}{"id"} =~ /0x05|0x07|0xc4|0xc5|0xc6|0xc7/) { print $disks->{$diskid}{"smart"}{$smartentry}{"id"}." ".$disks->{$diskid}{"smart"}{$smartentry}{"name"}."\t".$disks->{$diskid}{"smart"}{$smartentry}{"raw_value"}."\t"; if ($disks->{$diskid}{"smart"}{$smartentry}{"raw_value"} =~ /0|0\/0/) { @@ -135,12 +135,12 @@ while () { my %disks = getdisks(); my $batchcount = keys %disks; print "About to wipe ".$batchcount." drives with the following serial numbers:\n"; - foreach my $diskid (keys %disks) { + foreach my $diskid (sort {$a cmp $b} keys %disks) { print $disks{$diskid}{"serial"}."\n"; } anykey("Hit any key to continue...\n"); - foreach my $diskid (keys %disks) { - print "\e[J"; + foreach my $diskid (sort {$a cmp $b}keys %disks) { + print "\e[0;0H\e[2J"; # move cursor to 0,0 and then clear all text below. print "="x33; printf '[ %-10s ]', $diskid; print "="x33;