in reply to using scp package and options

My completely biased advise is that you should go with Net::OpenSSH instead:
use Net::OpenSSH; $ssh = Net::OpenSSH->new($server, port => $port, batch_mode => 1, user => $user, key_path => $identity_file, master_opts => ['-C', '-oStrictHostKeyCheckin +g=no']); $ssh->scp_put($local_file, $remote_file) or die "scp_put failed: ".$ss +h->error;

Replies are listed 'Best First'.
Re^2: using scp package and options
by toohoo (Beadle) on Feb 11, 2015 at 16:37 UTC

    Thank you for your answer.

    If you would mind helping me again please, I would appreciate your answers to some extra questions. But before, yes I did read the documentation under CPAN.org .

    1. It has to be "($server," instead of "(host => $server," ? I only want to be sure in this.
    2. Is it right, that the batchmode option is automatically set?
    3. Is it so that the protocol to set to 2 is not necessary?
    4. Doesnt $ssh have to closed like $ssh->quit or that way?

    Thanks in advance, Have a nice day, Thomas

      1: Both ways are valid:
      $s1 = Net::OpenSSH->new($host, ...); $s2 = Net::OpenSSH->new(host => $host, ...);

      2: No, by default Net::OpenSSH let's ssh ask you questions. If you want batch mode you have to state it:

      $s = Net::OpenSSH->new($host, batch_mode => 1, ...)

      3: Yes because Net::OpenSSH only works with version 2 of the protocol. SSH v1 is not supported.

      4: The connection is closed automatically when the object goes out of scope. You can close it explicitly if you want:

      $s->disconnect;

      update: disconnect method is only available in the latest development versions.

      Also, if you need to connect using SSH v1, my other module Net::SSH::Any does support it.