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

I am receiving the following when trying to SCP a file from a (local) host to a remote host.. it's very odd because the file transfers with no issue even though the error appears...

scp timed out while trying to connect to HOSTNAMEHERE at test.pl line 37

Here is my code snippet, all variables are defined correctly above in the script, I am also able to ssh and scp manually with no errors..

sub scp_stdby_config { my $scpe = Net::SCP::Expect->new; $scpe->login("oracle", "$o_ps"); $scpe->scp("/amp/oracle/cmerch1/test.txt", "$s_node_1:/amp/dep +ot/upgrade/transient/autoupgrade/configfiles/"); } scp_stdby_config();

Replies are listed 'Best First'.
Re: Issues with Net::SCP::Expect
by haukex (Archbishop) on Dec 03, 2019 at 18:21 UTC

    Net::SCP::Expect was last released 10 years ago and has several open issues. Since you seem to be running on a *NIX system and running an external ssh doesn't seem to be an issue, I'd strongly suggest you try Net::OpenSSH instead (see its scp_get and scp_put methods).

      Thanks haukex, I ended up implementing Net::OpenSSH and used the scp_put.

Re: Issues with Net::SCP::Expect
by Merchlewitz (Novice) on Dec 03, 2019 at 17:44 UTC

    I have ran a -d:Trace and have found the following:

    Problem performing scp: >> /amp/oracle/perl5/lib/perl5/Expect.pm:173: { exec(@cmd) }; >> /amp/oracle/perl5/lib/perl5/Expect.pm:173: { exec(@cmd) }; at test.pl line 39

      If you don't mind you probably should just use the build in /usr/bin/scp, it's better than every perl module I've tried and just works.

      I do this in every script where scp is needed.

        If you don't mind you probably should just use the build in /usr/bin/scp, it's better than every perl module I've tried and just works.

        Really, even better than Net::OpenSSH? Scripting an external binary is a tricky and brittle thing to do (see e.g. here), and not something I'd recommend if there's a module that already does the task well, otherwise one is just reinventing the wheel.