ovedpo15 has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to write a perl script which copies a directory with files from other machine to current machine.
I can use the scp command in shell but it requires a password.
Also I don't have the following modules insatlled on my work area (and unfortunately I cant install them):
Net::OpenSSH
Net::SSH::Perl
Net::SCP
Net:: FTP
I do have installed Net::SSH
My mission is to copy the files from other machine to current machine.
The main problem is that it requires a password to use scp on shell. Is there any elegant way to solve this problem?
  • Comment on copying directory from other machine to local machine

Replies are listed 'Best First'.
Re: copying directory from other machine to local machine
by marto (Cardinal) on Mar 11, 2018 at 16:18 UTC

    Depending on your needs you could configure your systems to use keys rather than prompt for passwords. Regarded perl modules see Yes, even you can use CPAN. cpanm & local::lib make this easy from a technical standpoint.

Re: copying directory from other machine to local machine
by karlgoethebier (Abbot) on Mar 11, 2018 at 17:16 UTC
    "...copies...files from other machine to current machine... elegant way..."

    I just remembered that rsync might be an option. See also File::Rsync and sshpass.

    Best regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

    perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Re: copying directory from other machine to local machine
by hilitai (Monk) on Mar 11, 2018 at 20:52 UTC

    Can you break this problem apart? Use perl to generate the list of files, then call scp to transfer the files? You should be able to get around the password prompts if you can set up passwordless ssh between the two machines.

Re: copying directory from other machine to local machine
by haukex (Archbishop) on Mar 11, 2018 at 19:12 UTC
A reply falls below the community's threshold of quality. You may see it by logging in.