Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- #Test Perl Script
- use strict;
- use warnings;
- #Used to capture text run by any system output
- my $systemOutputTemp;
- my @enclosureSlotArray = ();
- my $byIDFile;
- if (defined $ARGV[0])
- {
- print("Arguement found.\n");
- my $pdFile = $ARGV[0];
- open( FH, '<'. $pdFile) or die "Unable to find file!\n";
- my $enclosureIDTemp;
- my $slotNumberTemp;
- while (my $row = <FH>)
- {
- if ($row =~ m/^Slot Number: ([0-9]+)/)
- {
- $slotNumberTemp = $1;
- # printf("Found a Slot Number! The number is: %d\n", $slotNumberTemp);
- }
- if ($row =~ m/^Enclosure Device ID: ([0-9]+)/)
- {
- $enclosureIDTemp = $1;
- # printf("Found an Enclosure ID! The ID is: %d\n", $enclosureIDTemp);
- }
- if ($row =~ m/^Firmware state: Unconfigured/)
- {
- print("Found Unconfigured.\n");
- printf("Found Enclosure ID: %d \n", $enclosureIDTemp);
- printf("Found Slot Number: %d \n", $slotNumberTemp);
- my @temporaryEnclosureSlotArray = ($enclosureIDTemp, $slotNumberTemp);
- print("Printing the tempoarary enc-slot array...\n");
- print("@temporaryEnclosureSlotArray\n");
- push @enclosureSlotArray, \@temporaryEnclosureSlotArray;
- }
- }
- close FH;
- }
- #print("@enclosureSlotArray\n");
- print("$enclosureSlotArray[0][1]\n");
- my $testMatchValue = '0-scsi-0:2:' . $enclosureSlotArray[0][1] . ':0 -> ../../';
- print("$testMatchValue\n");
- #foreach my $driveTarget (@enclosureSlotArray)
- #{
- # print($driveTarget);
- # foreach my $element ($@driveTarget)
- # {
- # print("$element\n");
- # }
- #}
- #$systemOutputTemp = `ls -lv /dev/disk/by-path`;
- #print("Printing the System Output\n");
- #print($systemOutputTemp);
- if (defined $ARGV[1])
- {
- print("Second arguement found.\n");
- $byIDFile = $ARGV[1];
- open( FH, '<'. $byIDFile) or die "Unable to find file!\n";
- while (my $line = <FH>)
- {
- if ($line =~ m/$testMatchValue/)
- {
- print("Found");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement