scp.py icon indicating copy to clipboard operation
scp.py copied to clipboard

scp doesn't check the exit code of the remote command (needed for Windows)

Open madscientist opened this issue 3 years ago • 1 comments

scp doesn't check the exit code of the remote scp operation.

Unfortunately the scp command that comes with Windows 10 apparently doesn't provide any error messages at all on failure: if the scp fails the ONLY way to know is to see that the remote exited with a non-zero code. Unfortunately with no messages there's no way to know why it failed, but that's a problem in the Windows10 scp program that we can't do anything about. However, we can report the exit code.

FYI, here's the interesting output of running a local scp -v -v from my GNU/Linux system to a remote Windows10 system, copying a file down from the Windows system to my local system.

First here's a successful copy for an existing file:

debug1: Sending command: scp -v -f foobar
 ...
debug2: channel_input_status_confirm: type 99 id 1
debug2: exec request accepted on channel 1
Sink: C0666 5 foobar
debug2: channel 1: rcvd ext data 36
Sending file modes: C0666 5 foobar
debug2: channel 1: written 36 to efd 7
debug2: channel 1: rcvd eof
 ...
debug1: Exit status 0

Now here's a request for a non-existent file:

debug1: Sending command: scp -v -f foobar.xx
  ...
debug2: channel_input_status_confirm: type 99 id 1
debug2: exec request accepted on channel 1
debug2: channel 1: rcvd eof
  ...
debug1: Exit status 1

madscientist avatar Jan 08 '21 17:01 madscientist

FTR this is also an issue with servers that don't support SCP (i.e. where the command is missing). There, the EC is 127.

MrMino avatar Nov 07 '22 22:11 MrMino