Technext has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; use Cwd; use File::Copy; use Getopt::Long; use Net::SSH::Perl; use Net::SCP::Expect; my ($war_name, $wrapper_name, $host, $user, $war_build_path, $war_full +_path, $war_archive_path, $war_archive_host, $HOME, $scpe, @id_file); usage() if ( @ARGV < 6 or !GetOptions( 'war_name:s' => \$war_name, 'war_path:s' => \$war_build_path, 'wrapper_name:s' => \$wrapper_name, 'host=s' => \$host, 'user=s' => \$user, ) ); if ($war_name && $war_build_path && $host && $user) { printf "Initiating subroutine to copy war on remote machine...\n"; ©_war; } sub copy_war { $war_full_path = "/home/tom/slave/workspace/Rel_Build/rec_dist/$wa +r_name"; $war_archive_path = "/home/tom"; $war_archive_host = "xx.xxx.xxx.xx"; if ( -f $war_full_path ) { printf "Copying war: $war_name\n"; printf "Target Machine: $host\n"; printf "User: $user\n\n"; $scpe = Net::SCP::Expect->new( identity_file => "/home/tom/.ssh/i +d_file", host => $host, user => $user, ); $scpe->scp("$war_full_path", "$HOME") or die $scpe->{errstr}; printf "War copied on deployment machine. Now moving on to nex +t task of archiving the war...\n"; $scpe = Net::SCP::Expect->new( identity_file => "/home/tom/.ssh/i +d_file", host => $war_archive_host, user => $user, ); $scpe->scp("$war_full_path", "$war_archive_path") or die $scpe +->{errstr}; printf "War archived on master\n"; } else { printf "War not found\n"; } }
Output:
Initiating subroutine to copy war on remote machine... Copying war: remote-web.war Target Machine: xx.xxx.xxx.xx User: tom Use of uninitialized value $HOME in string at /home/tom/deploy.pl line + 59. War copied on deployment machine. Now moving on to next task of archiv +ing the war... at /home/tom/perl/5.18.2/lib/site_perl/5.18.2/Expect.pm line 760. I tried reading Expect.pm file around the error # but couldn't underst +and. Does it has anything to do with the earlier object not getting f +reed up? I couldn't find any method on the CPAN page for this module +to close the connection.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Unable to do SCP on multiple machines using Perl's Net::SCP::Expect module
by wjw (Priest) on May 02, 2014 at 15:28 UTC | |
by Technext (Acolyte) on May 03, 2014 at 18:12 UTC | |
|
Re: Unable to do SCP on multiple machines using Perl's Net::SCP::Expect module
by salva (Canon) on May 02, 2014 at 22:27 UTC | |
by Technext (Acolyte) on May 03, 2014 at 18:23 UTC | |
by salva (Canon) on May 03, 2014 at 19:51 UTC | |
by Technext (Acolyte) on May 05, 2014 at 10:14 UTC | |
by salva (Canon) on May 05, 2014 at 10:32 UTC | |
|