corected some syntax errors with sorting and output
This commit is contained in:
parent
21e03eb0a5
commit
c2a8181ce0
11
wipe.pl
11
wipe.pl
@ -48,12 +48,12 @@ sub uniq {
|
|||||||
|
|
||||||
# To get the list of devices we will be cleaning
|
# To get the list of devices we will be cleaning
|
||||||
sub getdisks {
|
sub getdisks {
|
||||||
my $devices = `find /dev/sd*[a-z]`;
|
my $devices = `find /dev -name "sd*[a-z]"`;
|
||||||
my %listhash = ();
|
my %listhash = ();
|
||||||
foreach(split("\n",$devices)) {
|
foreach(split("\n",$devices)) {
|
||||||
my $devicepath = $_;
|
my $devicepath = $_;
|
||||||
my $serial = `udevadm info --query=all --name=$_ | grep SERIAL_SHORT | sed -e 's/^.*=//'`;
|
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( $serial );
|
||||||
chomp( $model );
|
chomp( $model );
|
||||||
if ( $serial && $model ) {
|
if ( $serial && $model ) {
|
||||||
@ -135,12 +135,13 @@ while () {
|
|||||||
my %disks = getdisks();
|
my %disks = getdisks();
|
||||||
my $batchcount = keys %disks;
|
my $batchcount = keys %disks;
|
||||||
print "About to wipe ".$batchcount." drives with the following serial numbers:\n";
|
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";
|
print $disks{$diskid}{"serial"}."\n";
|
||||||
}
|
}
|
||||||
anykey("Hit any key to continue...\n");
|
anykey("Hit any key to continue...\n");
|
||||||
foreach my $diskid (sort {$a cmp $b}keys %disks) {
|
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;
|
print "="x33;
|
||||||
printf '[ %-10s ]', $diskid;
|
printf '[ %-10s ]', $diskid;
|
||||||
print "="x33;
|
print "="x33;
|
||||||
@ -163,6 +164,6 @@ while () {
|
|||||||
print join("\n",sort {$a cmp $b} uniq(@failed));
|
print join("\n",sort {$a cmp $b} uniq(@failed));
|
||||||
@failed = ();
|
@failed = ();
|
||||||
@good = ();
|
@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");
|
anykey("Hit any key when ready to continue...\n");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user