in reply to Re^2: scp recommendations
in thread scp recommendations

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.

Replies are listed 'Best First'.
Re^4: scp recommendations
by ikegami (Patriarch) on Aug 02, 2010 at 03:51 UTC
    # 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);
      well, actually it should be...
      my $quoted_to = text_to_shell_lit($to); system 'scp', '--', $from, "${host}:$quoted_to";
      or
      my $quoted_from = text_to_shell_lit($from); system 'scp', '--', "${host}:$quoted_from", $to;
        Oh! I see what you were saying now.