PERL   66

getinto

Guest on 22nd September 2022 12:37:52 AM

  1. #!/usr/bin/perl
  2. $BackupScripts=`pwd`;
  3. chomp $BackupScripts;
  4. $BackupSettings="$BackupScripts/settings";
  5. if (-f "$BackupSettings/settings.pl") { do "$BackupSettings/settings.pl"; }
  6. $TabFile=$ARGV[0];
  7. chomp $TabFile;
  8. $Verbose="no";
  9. if ($ARGV[1] =~ /--verbose/) {
  10.   $Verbose="yes";
  11. }
  12.  
  13.  
  14. open (TABFILE, "$TabFile") || die "Can't open tabfile $TabFile.\n";
  15. if ($Verbose eq "yes") { print "Getting system info...\n"; }
  16. while (<TABFILE>) {
  17.   $Line=$_;
  18.   chomp $Line;
  19.   if ($Line !~ /^#/) {
  20.     ($HostName,$RemoteCommand,$OutFile)=split (/:/,$Line,4);
  21.     if ($Verbose eq "yes") { print "$HostName:$RemoteCommand > $BackupRoot/$HostName/$OutFile\n"; }
  22.     open (OUTFILE, "> $BackupRoot/$HostName/$OutFile");
  23.     open (OUTPUT, "ssh $HostName $RemoteCommand |");
  24.     while (<OUTPUT>) {
  25.       print (OUTFILE $_);
  26.     }
  27.     close (OUTPUT);
  28.     close (OUTFILE);
  29.   }
  30. }
  31. close (TABFILE);

Raw Paste


Login or Register to edit or fork this paste. It's free.