I have been learning Perl, so if this is too simple I am sorry. I needed a way to copy the file outputs of the nmon script I run on AIX machines. I wanted to move them to a single machine where there is plenty of disk for it. This is what I came up with.
#!/usr/bin/perl -w =head1 Author: TechFly Name: nmoncopy.pl Description: Copy all nmon files from the /tmp/nmonout folders on the +machiens listed in the machinelistfilename. This will create a direc +tory on the destination if needed, and will use SCP to copy the files +. Then it will use SSH and delete the files (less two days from runt +ime) from the source. Start date: 7-20-2010 Last updated Date: 7-20-2010 =cut use strict; use warnings; use Net::SCP qw(scp); use Net::SSH qw(ssh); my $scp; my $machinelist; my $machinelistfilename = "./machinelist.txt"; my $server; open($machinelist, "<", $machinelistfilename)||die $!; print("\n"); while($server = <$machinelist>){ chomp($server); if(-d "./$server"){ copydata(); }else{ mkdir($server)||die $!; copydata(); } } sub copydata{ $scp = Net::SCP->new($server, "username"); $scp->get("/tmp/nmonout/*", "/export/nmon/$server/") or die $s +cp->{errstr}; ssh($server, "find /tmp/nmonout/ -mtime +2 |xargs rm"); }
In reply to File copier by TechFly
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |