corected some syntax errors with sorting and output

This commit is contained in:
bluesaxman 2019-06-26 13:14:05 -06:00
parent 21e03eb0a5
commit c2a8181ce0

11
wipe.pl
View File

@ -48,12 +48,12 @@ sub uniq {
# To get the list of devices we will be cleaning
sub getdisks {
my $devices = `find /dev/sd*[a-z]`;
my $devices = `find /dev -name "sd*[a-z]"`;
my %listhash = ();
foreach(split("\n",$devices)) {
my $devicepath = $_;
my $serial = `udevadm info --query=all --name=$_ | grep SERIAL_SHORT | sed -e 's/^.*=//'`;
my $model = `udevadm info --query=all --name=$_ | grep ID_MODEL | sed -e 's/^.*=//'`;
my $model = `udevadm info --query=all --name=$_ | grep "ID_MODEL=" | sed -e 's/^.*=//'`;
chomp( $serial );
chomp( $model );
if ( $serial && $model ) {
@ -135,12 +135,13 @@ while () {
my %disks = getdisks();
my $batchcount = keys %disks;
print "About to wipe ".$batchcount." drives with the following serial numbers:\n";
foreach my $diskid (sort {$a cmp $b} keys %disks) {
foreach my $diskid (sort {$disks{$a}{"serial"} cmp $disks{$b}{"serial"}} keys %disks) {
print $disks{$diskid}{"serial"}."\n";
}
anykey("Hit any key to continue...\n");
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.
# Disabling this because it just dosen't look good.
# print "\e[0;0H\e[2J"; # move cursor to 0,0 and then clear all text below.
print "="x33;
printf '[ %-10s ]', $diskid;
print "="x33;
@ -163,6 +164,6 @@ while () {
print join("\n",sort {$a cmp $b} uniq(@failed));
@failed = ();
@good = ();
print $color{"green"}."-"x34.$color{"red"}."\nWipe complete, insert more drives.\n".$color{"green"}."-"x34."\n";
print $color{"green"}.("-"x34).$color{"red"}."\nWipe complete, insert more drives.\n".$color{"green"}.("-"x34).$color{"reset"}."\n";
anykey("Hit any key when ready to continue...\n");
}