Advertisement
digimer

Untitled

Jan 11th, 2023
1,312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.78 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. # NOTE: We don't use Anvil::Tools to keep overhead low and to keep this agent independent as possible.
  4. use strict;
  5. use warnings;
  6.  
  7. # Turn off buffering so that the pinwheel will display while waiting for the SSH call(s) to complete.
  8. $| = 1;
  9.  
  10. # Log file
  11. our $log_file = "/var/log/anvil.log";
  12. open (my $log_fh, ">>", $log_file) or die "Failed to open: [".$log_file."] for writing. The error was: ".$!."\n";
  13. $log_fh->autoflush(1);
  14.  
  15. my $output      = "";
  16. my $call_string = "/usr/bin/virsh list --all";
  17. print $log_fh "Calling: [".$call_string."]\n";
  18. open (my $file_handle, "-|", $call_string) or die "Print: Failed to call: [".$call_string."]\n";
  19. while(<$file_handle>)
  20. {
  21.     chomp;
  22.     my $line = $_;
  23.     print $log_fh "line: [".$line."]\n";
  24. }
  25. close $file_handle;
  26.  
  27. exit(0);
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement