#!/usr/local/bin/perl #H# This script grabs usefull info like partition tables from a server being #H# backed up. #H# #H# Usage: #H# getinfo.pl [tabfile name] [-v] #H# #H# the tabfile is a colon seperated list of things to get in the following #H# format: #H# [remote username]:[remote hostname]:[command to run]:[file name for output] #H# example: #H# dementia:root:sfdisk -d /dev/sda:sda.sfdisk.txt #H# That will grab the partition table from dementia and store it in #H# /backup/rsync/dementia/sda.sfdisk.txt. $TabFile=$ARGV[0]; $Verbose="n"; if ($ARGV[1] =~ /-v/) { $Verbose="y"; } open (TABFILE, "$TabFile") || die "Can't open tabfile $TabFile.\n"; if ($Verbose eq "y") { print "Getting system info...\n"; } while () { $Line=$_; chomp $Line; if ($Line !~ /^#/) { ($UserName,$HostName,$RemoteCommand,$OutFile)=split (/:/,$Line,4); if ($Verbose eq "y") { print "$UserName\@$HostName:$RemoteCommand > /backup/rsync/$HostName/$OutFile\n"; } open (OUTFILE, "> /backup/rsync/$HostName/$OutFile"); open (OUTPUT, "ssh $UserName\@$HostName $RemoteCommand |"); while () { print (OUTFILE $_); } close (OUTPUT); close (OUTFILE); } } close (TABFILE);