digimer

Untitled

Dec 28th, 2011
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.71 KB | None | 0 0
  1. #!/usr/bin/perl
  2. #
  3. # This is a wrapper for dmidecode that will return the configured UUID
  4. # when 'dmidecode -s system-uuid' is called. Otherwise, it will call dmidecode
  5. # and return as appropriate.
  6. #
  7.  
  8. use strict;
  9. use warnings;
  10. use IO::Handle;
  11.  
  12. # Desired System UUID
  13. my $uuid="31873b9e-1069-42ce-b950-137ae5eaa3d1";
  14. my $exit=0;
  15.  
  16. # Read command line.
  17. my $cla="";
  18. foreach my $arg (@ARGV) { $cla.=$arg." "; }
  19. $cla=~s/\s+$//;
  20.  
  21. if ($cla eq "-s system-uuid")
  22. {
  23.     print $uuid, "\n";
  24. }
  25. else
  26. {
  27.     # Do a real dmidecode call.
  28.     my $sc="/usr/sbin/dmidecode $cla 2>&1 |";
  29.     my $fh=IO::Handle->new();
  30.     open ($fh, $sc) or die $!;
  31.     while (<$fh>)
  32.     {
  33.         print $_;
  34.     }
  35.     $fh->close();
  36.     $exit=$?;
  37. }
  38.  
  39. exit($exit);
Advertisement
Add Comment
Please, Sign In to add comment