Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: scp recommendations

by AndyZaft (Hermit)
on Jul 30, 2010 at 19:15 UTC ( [id://852155] : note . print w/replies, xml ) Need Help??


in reply to scp recommendations

I believe if you want to stay with core you will have to go with the system("scp $from $to") route. Otherwise Net::SFTP or Net::SCP is your best bet.

Replies are listed 'Best First'.
Re^2: scp recommendations
by ikegami (Patriarch) on Jul 30, 2010 at 22:13 UTC
    system("scp", "--", $from, $to)
    unless you want to spend time converting $from and $to into shell literals.
      That's not enough either as scp in order to run another scp as its slave in the remote side, calls ssh as...
      system('ssh', 'scp', '-t', @args)
      But the SSH protocol accepts only a single command string, ssh joins everything in one line and the command arrives at the remote machine as...
      system("scp -t @args")
      And it is called through the shell. That's why @args has to be escaped in order to avoid the remote shell doing unexpected things.
        # No good on Windows sub text_to_shell_lit { my ($s) = @_; $s =~ s/'/'\\''/g; return "'$s'"; }
        my $cmd = join ' ', map text_to_shell_lit($_), scp => '-t', @args; system(ssh => $cmd);
Re^2: scp recommendations
by syphilis (Archbishop) on Jul 31, 2010 at 00:38 UTC
    Otherwise Net::SFTP or Net::SCP is your best bet

    There's also Net::SSH2, which works well, is actively maintained, and has no requirements other than the libssh2 C library.

    Cheers,
    Rob
Re^2: scp recommendations
by salva (Canon) on Aug 01, 2010 at 19:28 UTC