Advertisement
Guest User

Untitled

a guest
Oct 17th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. #Test Perl Script
  4.  
  5. use strict;
  6. use warnings;
  7.  
  8. #Used to capture text run by any system output
  9. my $systemOutputTemp;
  10.  
  11. my @enclosureSlotArray = ();
  12. my $byIDFile;
  13. if (defined $ARGV[0])
  14. {
  15. print("Arguement found.\n");
  16.  
  17. my $pdFile = $ARGV[0];
  18.  
  19. open( FH, '<'. $pdFile) or die "Unable to find file!\n";
  20.  
  21. my $enclosureIDTemp;
  22. my $slotNumberTemp;
  23.  
  24. while (my $row = <FH>)
  25. {
  26. if ($row =~ m/^Slot Number: ([0-9]+)/)
  27. {
  28. $slotNumberTemp = $1;
  29. # printf("Found a Slot Number! The number is: %d\n", $slotNumberTemp);
  30. }
  31.  
  32. if ($row =~ m/^Enclosure Device ID: ([0-9]+)/)
  33. {
  34. $enclosureIDTemp = $1;
  35. # printf("Found an Enclosure ID! The ID is: %d\n", $enclosureIDTemp);
  36. }
  37.  
  38. if ($row =~ m/^Firmware state: Unconfigured/)
  39. {
  40. print("Found Unconfigured.\n");
  41. printf("Found Enclosure ID: %d \n", $enclosureIDTemp);
  42. printf("Found Slot Number: %d \n", $slotNumberTemp);
  43.  
  44. my @temporaryEnclosureSlotArray = ($enclosureIDTemp, $slotNumberTemp);
  45. print("Printing the tempoarary enc-slot array...\n");
  46. print("@temporaryEnclosureSlotArray\n");
  47. push @enclosureSlotArray, \@temporaryEnclosureSlotArray;
  48. }
  49. }
  50. close FH;
  51. }
  52.  
  53. #print("@enclosureSlotArray\n");
  54.  
  55. print("$enclosureSlotArray[0][1]\n");
  56. my $testMatchValue = '0-scsi-0:2:' . $enclosureSlotArray[0][1] . ':0 -> ../../';
  57. print("$testMatchValue\n");
  58.  
  59.  
  60. #foreach my $driveTarget (@enclosureSlotArray)
  61. #{
  62.  
  63. # print($driveTarget);
  64. # foreach my $element ($@driveTarget)
  65. # {
  66. # print("$element\n");
  67. # }
  68. #}
  69.  
  70. #$systemOutputTemp = `ls -lv /dev/disk/by-path`;
  71. #print("Printing the System Output\n");
  72. #print($systemOutputTemp);
  73.  
  74. if (defined $ARGV[1])
  75. {
  76. print("Second arguement found.\n");
  77. $byIDFile = $ARGV[1];
  78. open( FH, '<'. $byIDFile) or die "Unable to find file!\n";
  79.  
  80. while (my $line = <FH>)
  81. {
  82. if ($line =~ m/$testMatchValue/)
  83. {
  84. print("Found");
  85. }
  86. }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement