Scp with pending module not working
I wrote the following program to automate the scp command in perl.
#!/usr/bin/expect
spawn scp hscpe@9.126.134.54:/home/hscpe/output.txt 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!..
+3
user650521
source
to share
3 answers
use Net :: OpenSSH :
my $ssh = Net::OpenSSH->new('hscpe@9.126.134.54', password => 'jujsa32s');
$ssh->scp_get('/home/hscpe/output.txt', 'imt/output.txt');
+2
salva
source
to share
You are using wait for your password.
I think you should be using expect.pm for this task. The environment used when running the perl script may miss expected parts.
0
weismat
source
to share
You must use "sshpass" in your bash script:
#!/bin/bash
sshpass -p "password" scp -r user@example.com:/some/remote/path /some/local/path
0
KevinS
source
to share