Reputation: 41
I am copying the files from one host to another using:
Net:scp::Except;
here is my script
use strict; use Net::SCP::Expect;
print "enter user name\n"; my $username = <>;
print "enter password\n"; my $pass = <>;
print "enter host name\n"; my $host = <>;
my $src_path = "/"; my $dst_path = "/";
my $scpe = Net::SCP::Expect->new(user=>$username, password=>$pass, auto_yes=> '1'); $scpe->scp($host.":".$src_path, $dst_path);
getting error like bad password
Upvotes: 1
Views: 661
Reputation: 4371
You're receiving those variables from STDIN and they all include a trailing \n
. You'll want to chomp
them before use:
chomp ($username,$pass,$host);
my $scpe = Net::SCP::Expect->new(user=>$username, password=>$pass, auto_yes=> '1');
$scpe->scp($host.":".$src_path, $dst_path);
Net::SCP::Expect runs the scp program with a command line stitched together from your parameters. So, without chomping it will effectively be truncated to scp yourusername
Upvotes: 1