Perl script to ssh fron Node_A to many Nodes and find specific logs and scp them back over to Node A -


running following problem on perl script, i'm trying ssh host, find specific logs, , scp them over. fails:

#!/usr/bin/perl ############################ use strict; use warnings;  ###pulling hosts file $nodes = '/tmp/all-servers.txt'; open $handle, '<', $nodes; chomp (my @hosts = <$handle>); close $handle;  chomp (my $user  = "user");  ### go through nodes, find logs, , scp them on node_a foreach $host (@hosts) {  $output = `ssh $user\@$host  find /tmp -maxdepth 1 -type f -name *test* | xargs -i{} scp {} $user\@node-a:/home/logs`;  } 

the scp fails, i'm assuming fails because data scalar still in memory?

does work command line? seems pipe not part of ssh command, scp runs same server perl script running - in contradiction describe.

also, should quote *test*, shell might expand asterisks random files appearing in working directory.

also, scp doesn't return reasonable output, i'd go system instead of `...`.

my $status = system qq< ssh $user\@$host 'find /tmp -maxdepth 1 -type f -name "*test*" >                   . qq< | xargs -i{} scp {} $user\@node-a:/home/logs' >; 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -