Scp with pending module not working

I wrote the following program to automate the scp command in perl.

spawn scp hscpe@ imt
set pass "jujsa32s"
expect {
        password: {send "$pass\r"; exp_continue


But no file transfer happens. Usually on the console if I tried the same scp command it works fine. Can anyone figure out the problem

Thanks in advance!..


source to share

3 answers

use Net :: OpenSSH :

my $ssh = Net::OpenSSH->new('hscpe@', password => 'jujsa32s');
$ssh->scp_get('/home/hscpe/output.txt', 'imt/output.txt');




You are using wait for your password.
I think you should be using for this task. The environment used when running the perl script may miss expected parts.



You must use "sshpass" in your bash script:

sshpass -p "password" scp -r /some/local/path




All Articles